PDA

View Full Version : php qry INSERT just not workin


sir pannels
05-14-2003, 12:19 PM
hey,
maybe you guys can see something i cant but, it just says could not execute querry, the table and db is correctly named
<?

$conn = @mysql_connect("localhost","","")
or die("Could not connect to MySQL");

$db = @mysql_select_db("sirp_archive",$conn)
or die("Could not select database");

$sql = "insert into users (username,email,password)
values (\"$username\", \"$email\", \"$password\")";

$result = @mysql_query($sql,$conn)
or die("Could not execute query");

any ideas?
its really puzzlein
cheers :thumbsup:

raf
05-14-2003, 12:33 PM
Why double quotes? Textvalues should have single quotes.
Also, mysql_query() only returns a resultidentifier if data is requested (like in a select statement) and not with an update statement. To check if the update was performed, use mysql_affected_rows ()
http://www.php.net/manual/en/function.mysql-affected-rows.php

whackaxe
05-14-2003, 03:18 PM
for simplicitys sake dont use

$sql = "insert into users (\"$username\",\"$email\",\"$password\")";


try

$sql = "INSERT INTO users('$username','$email','$password')";


also, use the mysql_error() and mysqlerrorno() functions to get the errors from the databse. although mysql errors are as crytic and vague as hell

Fatman
05-14-2003, 04:09 PM
siwcth ya \" for '

and use echp mysql_error()

whackaxe
05-14-2003, 05:19 PM
try reading a thread before posting fatman, i just said exactly what you did :|