By lucasvm on
Hello
How do i know if an insert query was done?...im doing...
$sql = "INSERT INTO db(table) VALUES('$value')";
or die = print = "There was an Error";
of course...or die..doesnt work...what can i do?
Hello
How do i know if an insert query was done?...im doing...
$sql = "INSERT INTO db(table) VALUES('$value')";
or die = print = "There was an Error";
of course...or die..doesnt work...what can i do?
Comments
why not use the drupal API?
why not use the drupal API? http://api.drupal.org/api/function/drupal_write_record/6
You should be using the
You should be using the Database abstraction layer: http://api.drupal.org/api/group/database/6 . The db_query function: http://api.drupal.org/api/function/db_query/6 returns a boolean false if there was an error executing the query.
So something like:
@studley181 Did you really
@studley181
Did you really mean to say
Shouldn't it be
?
thank you for your
thank you for your explain...im trying to do this:
[PHP]
$total = db_result(db_query('SELECT * FROM users WHERE users.name='.$login));
if ($total > 0 ) {
print "The user '.$login.' exists" codigo="0"/>';
}
else{
$sql = "INSERT INTO users(uid,pass,mail) VALUES('$login','$password','$mail')";
$result = db_query($sql);
if ($result == FALSE) {
prnt "There was an error";
} else {
print "The query was ok";
}
[/PHP]
Im always getting there was an error and tne insert into doesnt work....what im doing wrong?
Does the comment on this page
Does the comment on this page help you?
http://api.drupal.org/api/function/user_authenticate
Right, that's what I meant.
Right, that's what I meant.