Hello everyone I am getting a, after my result in the databases here is my code
<input type="text" size="49" maxlength="40" name="image2">
$_SESSION['image'] = $image ;
mysql_query("INSERT INTO adds (username, url, coins, image) VALUES('".$_SESSION['username']."','".$_SESSION['url']."', '".$_SESSION['perclick'].",', 开发者_StackOverflow'".$_SESSION['image'].",' ) ") or
die(mysql_error());
So if there is nick in side $_SESSION['image']
it would show has nick, in the db the column is varchar
if I change it to int
and enter a number it adds the number with out the , at the end
The quotes in the query are what are confusing. Let me use PHP's inline variables to help make this more clear.
"VALUES('{$_SESSION['username']}','{$_SESSION['url']}', '{$_SESSION['perclick']},', '{$_SESSION['image']},' ) ") or die(mysql_error());
As is hopefully now evident, what is being inserted as image
is actually {$_SESSION['image']},
. Also be aware that the same thing is occurring for coins
.
VALUES (
'".$_SESSION['username']."',
'".$_SESSION['url']."',
'".$_SESSION['perclick'].",', // here is one
'".$_SESSION['image'].",' // and here's another
)
should be like this
VALUES (
'".$_SESSION['username']."',
'".$_SESSION['url']."',
'".$_SESSION['perclick']."',
'".$_SESSION['image']."'
)
VALUES('".$_SESSION['username']."','".$_SESSION['url']."', '".$_SESSION['perclick']."', '".$_SESSION['image']."' )
精彩评论