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!

PHP MySQL syntax error - please help

Status
Not open for further replies.

kaul1jos

Technical User
Jan 5, 2001
76
NL
I need to update a field of a database with the following content:
$ILO__NaamIp = 'RILO: SERVER - 145.78.1.119';
$svr = SERVER ;

I tried:
$sql = 'UPDATE `tbl_serverinfo` SET `ILO_NaamIp` = '.$ILO__NaamIp.'WHERE `ServerNaam` = '.$svr.' LIMIT 1';

and got the following error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ': SERVER - 10.0.0.9

Please help
 
You need singlequotes inside your query, so use doublequotes as your string limiter when constructing the query:

Code:
<?php
$ILO__NaamIp = 'RILO: SERVER - 145.78.1.119';
$svr = 'SERVER' ;

$sql = "UPDATE `tbl_serverinfo` SET `ILO_NaamIp` = '" . $ILO__NaamIp . "' WHERE `ServerNaam` = '" . $svr . "' LIMIT 1";
?>

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top