PDA

View Full Version : What wrong with this query ?



GregT
July 30th, 2003, 01:27
PHP tells me this query is invalid

$insert = mysql_db_query("INSERT INTO ds_articles VALUES ('$name','$text','$authorn', '$date')");

Warning: Wrong parameter count for mysql_db_query() in /home/zero/public_html/devplace/beta/admin/newarticle.php on line 21

Adding it manually like this

INSERT INTO ds_articles
VALUES (
'Test Article', 'Testing !!! 123...', 'Zero', '12.02.05'
)

through phpmyadmin works :confused:

Please help me !

dawizman
July 30th, 2003, 01:51
It's mysql_query, not mysql_db_query:




$insert = mysql_query("INSERT INTO ds_articles VALUES ('$name','$text','$authorn', '$date')");

GregT
July 30th, 2003, 01:54
Yea, i figured that out a couple seconds after I posted :P

GregT
July 30th, 2003, 01:57
Now I have another question, I get no errors on this, but when I do it the author table comes up empty


$result = mysql_query("SELECT `nickname` FROM `ds_users` WHERE username='" . addslashes($author) . "' LIMIT 1");
$author = mysql_fetch_row($result);
addslashes("$name");
addslashes("$text");
addslashes("$author");
addslashes("$date");

$insert = mysql_query("INSERT INTO ds_articles VALUES ('$name','$text','$author', '$date')");


I believe it's because of improper use of mysql_fetch_row ?

GregT
July 30th, 2003, 02:29
Edit: Figured it out again, i was missing $author = $author[0];