diokhan Posted December 30, 2009 at 10:56 AM Report Share #303154 Posted December 30, 2009 at 10:56 AM boas, eu tenho uma duvida, eu tenho na base de dados o campo COMMENTS, e é do tipo TEXT, e na minha pagina tenho como inserir o COMMENTS numa TEXTAREA, mas sempre que faço o INSERT o campo COMMENTS fica em branco, eu deixo aqui um pouco do código se alguém puder ajudar-me a ver o que estou a fazer de errado ? este é o código onde posso inserir novos dados: <?php echo" <table> <h2 align=center>New Enzyme:</h2><hr> <form action='enzyme/insertEnzyme.php' method='POST'> <tr> <td>Accepted Name:</td> <td><input type='text' name='acceptedName' size='70'></td> </tr><tr> <td>Other Name:</td> <td><input type='text' name='otherName' size='70'></td> </tr><tr> <td>Systematic Name:</td> <td><input type='text' name='systematicName' size='70'></td> </tr><tr> <td>E.C.:</td> <td><input type='text' name='ec' size='70'></td> </tr><tr> <td>Comments:</td> <td><textarea name='comments' rows='5' cols='5' style='width: 99%;'></textarea></td> </tr><tr> <td colspan='2' align=center><hr> <input type='submit' value='New Enzyme'> <input type='reset' value='Clear'> </td> </tr> </form> </table>"; ?> aqui apanho os valores enviados pelo ficheiro anterior: <?php require_once ('../functions.php'); $reg = new Enzyme; $reg->SetAcceptedName($_POST['acceptedName']); $reg->SetOtherName($_POST['otherName']); $reg->SetSystematicName($_POST['systematicName']); $reg->SetEC($_POST['ec']); $reg->SetComments($_POST['comments']); $error = $reg->newEnzyme(); if(!empty($error['2'])) { echo $error['2']; } header ('Location: ../restrito.php?opcao=view_enzyme'); ?> e aqui faço o INSERT: function newEnzyme() { $stmt= $this->dbh->prepare("INSERT INTO ENZYME (ACCEPTED_NAME, OTHER_NAME, SYSTEMATIC_NAME, EC, COMMENTS) VALUES (:acceptedName, :otherName, :systematicName, :ec, :comments)"); $stmt->bindParam(':acceptedName', $this->AcceptedName); $stmt->bindParam(':otherName', $this->OtherName); $stmt->bindParam(':systematicName', $this->SystematicName); $stmt->bindParam(':ec', $this->EC); $stmt->bindParam(':comments', $this->Comments); $stmt->execute(); $arr = array(); $arr = $stmt->errorInfo(); return $arr; } EDIT: esta duvida já foi resolvida, verifiquei o código e reparei que tinha um "n" no lugar de um "m", mas agora falta-me resolver a duvida seguinte, para mostrar os dados da tabela, os dados completos ? ...Join the dark side...and get a free cookie... Link to comment Share on other sites More sharing options...
diokhan Posted December 30, 2009 at 11:18 AM Author Report Share #303160 Posted December 30, 2009 at 11:18 AM e outra duvida que tenho, para não ter que criar um novo tópico coloco aqui porque uma duvida pode levar a outra. para mostrar os dados que tenho na tabela, eu faço assim: <?php require_once ('./admin/constantes.php'); $sql = "SELECT ID_ENZYME, ACCEPTED_NAME, OTHER_NAME, SYSTEMATIC_NAME, EC, COMMENTS FROM ENZYME WHERE ID_ENZYME = $_GET[id]"; foreach ($dbh->query($sql) as $row) { echo" <center> <h2>Edit Enzyme:</h2> <form action=enzyme/update_enzyme.php?id=$_GET[id] method='POST'> <tr> <td>Accepted Name:</td> <td><input type='text' name='acceptedName' value=$row[ACCEPTED_NAME] size='70'></td> </tr><tr> <td>Other Name:</td> <td><input type='text' name='otherName' value=$row[OTHER_NAME] size='70'></input></td> </tr><tr> <td>Systematic Name:</td> <td><input type='text' name='systematicName' value=$row[sYSTEMATIC_NAME] size='70'></td> </tr><tr> <td>E.C.:</td> <td><input type='text' name='ec' value=$row[EC] size='70'></td> </tr><tr> <td>Comments:</td> <td><textarea name='comments' rows='5' cols='5' style='width: 99%;'>$row[COMMENTS]</textarea></td> </tr><tr> <td colspan='2' align='center'> <input type='submit' id='Submit_btn' value='Save Changes'> <input type='button' value='Cancel' onclick=javascript:history.back()> </td> </tr> </form> </center> "; } ?> mas se na tabela os campos tiverem espaço, quando faço para mostrar os dados não mostra tudo, mostra a informação ate ao 1º espaço do campo e depois segue para o próximo, por exemplo, tenho na tabela "Felipe Santos" mas ao mostrar os dados aparece só "Felipe" B) ...Join the dark side...and get a free cookie... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now