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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysql query 2

Status
Not open for further replies.

PhoenixDown

Programmer
Jul 2, 2001
279
0
0
CA
I havent done php in a while so could someone tell me why this isn't working

include 'config.php';

$dbi = mysql_connect ("$server", "$user", "$pass") or die ("Error connecting.");
mysql_select_db ("$db") or die ("Error selecting database.");

$result = mysql_query("update news set views='".($views+1)."' where id='".$id."')", $dbi);

i printed it to the browser and the query looked okay, i just dont know whats wrong.
 
It says: "You have an error in your SQL syntax near ')' at line 1"
 
and 'lo and behold... look at your query, and you have a superflous )

that string comes out to

update news set views='4' where id='110')

Personally, I always like to do something like
$query = "string stuff and all the appending";

mysql_query($sql, $dbi);

so That if there's a problem with the SQL I can just dump it somewhere and look at it.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top