Click to See Complete Forum and Search --> : need help w/this php/sql script


neotrace
01-28-2002, 06:45 PM
ok, this is a php script that logs into a mysql database w/a speicfied username and password, that part works fine. The problem is with the log (the final if statement) that is suppose to write that information to the database? Any ideas?


create table log (
id int auto_increment not null,
name tinytext,
pass tinytext,
time timestamp(14),
primary key(id)
else{


$query = "insert into log (name,pass) values ('$USERNAME','$PASSWORD')";
$rs = mysql_query($query, $login->db_link);
}
?>

[ 28 January 2002: Message edited by: neotrace ]

Stuka
01-28-2002, 07:39 PM
What kind of errors do you get? Have you tested the query line for an error? If not, try that, and find out what kind of error code you get. If mysql_query() is returning FALSE, the query isn't quite right - check your variables, etc. If it is returning TRUE, use mysql_affected_rows() to see if it's changing anything. But the biggest help is to print out your variable values, and make sure they're valid.

neotrace
01-29-2002, 04:38 PM
how could I test the query line? Is it a command within mysql or do I alter the script?

vasah20
01-30-2002, 02:24 AM
just do:
print $query;

before you do any mysql_xxx calls. This way, you can see the query, and make sure that it's being formed the way you want it to.