Jump to content

Recommended Posts

Hi All,

I was just wondering if anyone could help me troubleshoot this error that I keep receiving. I am trying to delete something in a table if it is  already in there, and I keep receiving an error message that states that something is wrong with my syntax. I changed it around several times, but still nothing. Any suggestions?


$res=mysql_query("select * from End_Review");
if(mysql_num_rows($res)==0) echo "there is no data in table..";
if (mysql_num_rows($res)!=0)
{

for($i=0;$i<mysql_num_rows($res);$i++)
{
$row=mysql_fetch_assoc($res);

}
// $row is an array of titles
mysql_query("DELETE FROM End_Review WHERE $title==$row[topic_title]")
or die(mysql_error());
}


If it helps, this is how I input data into this table--it works fine.

mysql_query("INSERT INTO End_Review
(id,topic_title, date) VALUES('','$title','$test_date' ) ")
or die(mysql_error());


Link to comment
https://forums.phpfreaks.com/topic/14609-deleting-a-row-in-a-table/
Share on other sites

I think that topic_title in $row[topic_title] should be in quotes.

[code] mysql_query("DELETE FROM End_Review WHERE $title==$row[topic_title]") [/code]

Look at the "MySQL Related" section in [url=http://dptr1988.mooo.com/php_tips.php]PHP Coding tips[/url] for ideas on how to troubleshoot your MySQL query.
agreed about needing to compare an actual field with something.  jvroth fixed the actual issue without pointing it out - comparison in MySQL takes place with one equal sign, not two.  have a look in the MySQL manual at the comparison operators.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.