I have a Table Serial with 3 fields ID, FName, Lname
whe I type in with php
$user = "user";
$pass = "password";
$db = "Database";
$link = @mysql_connect( "localhost", $user, $pass );
if ( ! $link ) {
die( "Couldn't connect to MySQL: ".mysql_error() );
}
$sql = 'UPDATE `Serial` SET `FName` = \'Dick\' WHERE `ID` = \'3\'';
$result = mysql_query($sql ,$link );
it works but if I use a variable IT DOES NOT
$user = "user";
$pass = "password";
$db = "Database";
$link = @mysql_connect( "localhost", $user, $pass );
if ( ! $link ) {
die( "Couldn't connect to MySQL: ".mysql_error() );
}
$idnum = 3;
$sql = 'UPDATE `Serial` SET `FName` = \'Dick\' WHERE `ID` = $idnum';
$result = mysql_query($sql ,$link );
I get the following error
Unknown column '$idnum' in 'where clause'
HOW COME???
whe I type in with php
$user = "user";
$pass = "password";
$db = "Database";
$link = @mysql_connect( "localhost", $user, $pass );
if ( ! $link ) {
die( "Couldn't connect to MySQL: ".mysql_error() );
}
$sql = 'UPDATE `Serial` SET `FName` = \'Dick\' WHERE `ID` = \'3\'';
$result = mysql_query($sql ,$link );
it works but if I use a variable IT DOES NOT
$user = "user";
$pass = "password";
$db = "Database";
$link = @mysql_connect( "localhost", $user, $pass );
if ( ! $link ) {
die( "Couldn't connect to MySQL: ".mysql_error() );
}
$idnum = 3;
$sql = 'UPDATE `Serial` SET `FName` = \'Dick\' WHERE `ID` = $idnum';
$result = mysql_query($sql ,$link );
I get the following error
Unknown column '$idnum' in 'where clause'
HOW COME???