It's really not my first SQL query;), but ...!, I've a weird error : I am doing an import from a CSV file into my db, and the query returns an error with mysql_query, and in phpmyadmin, if I copy/paste the query, all is ok.
$result = mysql_query ($ sql);
echo $ sql. "=>". $result. ','. Mysql_error ($this-> cnx). '<br> cnx ='. $this-> cnx. '<br>';
In the echo :
INSERT INTO tiny_url (`id`, `url`, `tiny_url`, `page_rank`, `link_name`, `destination_url`, `anchor`, `active`) VALUES (NULL, "111", "222", 3, "444", "555", 1,1)
=>, 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 '
'At line 3
cnx = Resource id # 27
and if I do that : it works:
$sql = 'INSERT INTO tiny_url (`id`, `url`, `tiny_url`, `page_rank`, `link_name`, `destination_url`, `anchor`, `active `) VALUES (NULL," 111 "," 222 ", 3," 444 "," 555 ", 1,1) ';
$result = mysql_query ($sql);
echo $sql. "=>". $result. ','. mysql_error($this-> cnx). '<br> cnx ='. $this-> cnx. '<br>';
Can U help me please ?
Fab
mysql_*functions, it's deprecated (see red box) and vulnerable to sql-injection. Use PDO or MySQLi.INSERT?...VALUES (NULL," 111 "," 222 "...