Parse Error Inserting IP on the datae base
Why do I get this parse error message when I try to insert an ip into the data base.
Below is my code
Parse error: syntax error, unexpected T_DNUMBER
Now if I try to put single or double quote like this
mysql_query("INSERT INTO table_name(ip_string)
the error will be gone, but it will not insert into the data base
Last edited by anishgiri; 04-07-2013 at 10:47 PM.
Ok I solve it I put a quote in my sql statement. Sometimes I am really forget full of these syntax/rules..
Moving up to either the MySQLi extension or the PDO extension (instead of using the deprecated MySQL extension) can help you avoid that sort of problem by making use of prepared statements. It also automatically takes care of any escaping.
Originally Posted by anishgiri
$sql = "INSERT INTO table_name(ip_string) VALUES(?)";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('s', $ip2); // handles all quoting/escaping issues for you
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)