Jump to content

updating column leaves it blank.


thereaper87

Recommended Posts

Hello there. I have a small form the inputs a new message into the column 'status'. But when I insert the new text, it deletes whatever is already in the column and leaves it blank. It will never add the new text to the column.

 

Here is the form:

$status_sql=mysql_query("SELECT status FROM global");
  $status_data=mysql_fetch_assoc($status_sql);
  echo '<br /><br />Current Status Message: '.$status_data['status'].'<br />';
  echo '<form name="status" method="post" action="?page=panel&action=sdo"><input type="text" class="console" name="status"> <input type="submit" class="cbutton" value="Enter"></form>';

 

$status = mysql_real_escape_string($_POST['status']);
  $update=mysql_query("UPDATE global SET status='$status' WHERE id='1'") or die('Query: ' . $update . '<br />Failed with: ' . mysql_error());  
  echo '<br />Status changed to: '.$status.'';

 

If you need more info, just let me know.

 

Thank you a million!

Link to comment
https://forums.phpfreaks.com/topic/229084-updating-column-leaves-it-blank/
Share on other sites

Try this, on the line where the query should be happening:

echo "UPDATE global SET status='$status' WHERE id='1'";

 

I'm curious to see if $status is being set.  If not, and the query was "SET status='' WH..." that would at least help source the error.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.