View Full Version : PHP not interacting with MySQL correctly...

06-04-2011, 07:27 PM
So I have a page with a text area (I've replaced the text area with CKEditor, a rich text editor) that loads the content of a MySQL row into the text area. I would like to be able to then change the content of the row in the editor, hit the update button and be on my merry way. That doesn't want to work for some reason. Whenever I try to get it to update, it just deletes the contents of the table/row, and then leaves me back at square one. Damn computer.

Here's my update script:


$update = $_POST['post'];

$query = "UPDATE content SET pagestuff = '$update' ";
$results = mysqli_query($cxn,$query);

and my form:

<form action="../scripts/repspecials.php" enctype="multipart/form-data" name="form1" id="form1">
<span style="text-align:center"><p>
<textarea id="post" name="post"><?php
echo $row['pagestuff'];
<strong>Please enable JavaScript in your browser to use the full page editor. Otherwise, you'll have to stick with the one above.</strong></noscript>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<td width="16%" style="text-align:center"><label for="password">Password:</label></td>
<td width="34%" style="text-align:center"><input type="password" name="password" id="password" /></td>
<td width="25%" style="text-align:center"><strong>..............................</strong></td>
<td width="25%"><label for="update"></label>
<input type="submit" name="update" id="update" value="Update" /></td>

The thing is, I have another page that loads the content of the table/row, and then displays it on the screen. That works fine. It's just the updatin' process that kicks the crap out of schedule (I'm runnin' out of time here!):-D

06-06-2011, 04:32 PM
try telling MySQL which row to update.

$query = "UPDATE content SET pagestuff = '$update' WHERE id = 'id number here' ";

06-06-2011, 06:23 PM
try telling MySQL which row to update.

Oh my God, you're awesome. I don't know why I thought it would automatically find it :grin: