简体   繁体   中英

mysql insert query does not work from php

$qry ="insert into `$table`(Number) values('".$msg2."')";
$result = mysql_query($qry);

If this query is executed from php, a new row is created but no value is getting inserted. Although the id column gets auto incremented. Is there anything wrong with the formatting of msg2?

请检查列的数据类型-PHPMYADMIN中的Number

Print the value of $qry and see if it's appropriate. IE if you paste it into mysql console would it do what you expect?

Also - use a prepared statement next time. This approach is prone to injection style attacks.

Pls check this one

$qry ="INSERT INTO $table(`Number`) VALUES ('$msg2')";
if($result = mysql_query($qry)){}
else{
 echo mysql_error();
}

Try with

$qry ="insert into `$table`(Number) values('$msg2')";
$result = mysql_query($qry);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM