Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem updating row

Status
Not open for further replies.

PhoenixDown

Programmer
Jul 2, 2001
279
CA
I'm having a problem updating row in MySQL.

$query = mysql_query("update table set message='$what' where id='$id'", $connect);
 
And?

Any errors?

Any strange behavior? ______________________________________________________________________
Never forget that we are
made of the stuff of stars
 
I made a commenting thing for my guestbook, but it only adds SOME comments:

$query = mysql_query("select message from table where id='$id'", $dbi);
list($message) = sql_fetch_row($query, $connect);

$what = &quot;$message<br><br>Comment by $admin[0]: $the_comment&quot;;

$query = mysql_query(&quot;update table set message='$what' where id='$id'&quot;,$connect);
 
What do you mean? Give me an example of a comment it will not add.

Does the comment have apostrophes or other mysql-sensitive data in it? If you, you might try running the user-supplied comment through mysql_escape_string() first. ______________________________________________________________________
Never forget that we are
made of the stuff of stars
 
An example comment would be:

message = Hi Cal, I sent a report to U. Enjoy...

I printed the query and this is what I got:

mysql_query(&quot;update table set message='Original message<br><br>Comment by Calvin: test' where id='40'&quot;,Resource id #1);

It still doesn't update it.

 
What error are you getting?

What does mysql_error() say? ______________________________________________________________________
Never forget that we are
made of the stuff of stars
 
It doesn't say anything.


$query = mysql_query(&quot;select message from table where id='$id'&quot;, $dbi);
list($message) = sql_fetch_row($query, $connect);

$what = &quot;$message<br><br>Comment by $admin[0]: $the_comment&quot;;

$query = mysql_query(&quot;update table set message='$what' where id='$id'&quot;,$connect);
mysql_error($query);
 
Try &quot;print mysql_error ();&quot; ______________________________________________________________________
Never forget that we are
made of the stuff of stars
 
Thanks, sleipnir214! I owe you one!

It's the ''s and &quot;'s that are in some of the entries that are causing the problem. I fixed it for those characters.
 
It's the apostrophes that are the source of a high percentage of data-driven SQL errors. ______________________________________________________________________
Never forget that we are
made of the stuff of stars
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top