| FAQ |
| Kalender |
|
|
#1 | ||
|
|||
|
Har WN som tidsfördriv
|
Hej gott folk
Har ett litet problem med att köra insert into i mySQL! Så här ser koden ut: Kod:
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
*{
*die('Could not connect: ' . mysql_error());
*}
mysql_select_db("my_db", $con);
$sql="INSERT INTO products (name, desc, points, img)
VALUES
('".$_POST['name']."','".$_POST['desc']."','".$_POST['points']."','".$_POST['img']."')";
if (!mysql_query($sql, $con))
*{
*die('Error: ' . mysql_error());
*}
echo "Added!";
}
Kod:
Error: 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 '2, 3, 4) VALUES ('1','2','3','4')' at line 1
Kod:
$result = mysql_query("INSERT INTO table (1, 2, 3, 4)
VALUES ('".$_POST['1']."', '".$_POST['2']."', '".$_POST['3']."', '".$_POST['4']."')");
Tacksam för svar! //Philip Andersson
|
||
|
|
Svara med citat
|
| Ämnesverktyg | |
| Visningsalternativ | |
|
|