Whats wrong here?

matrixweb

Expert Member
Joined
Apr 7, 2008
Messages
1,210
PHP:
$online = "INSERT INTO xtwf_online (uname, place) VALUES ('$user', 'Just logged in' )";  
mysql_query( $online );

it looks right to me but it doesnt work , no error but it doesnt insert the values
 

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
How fussy is MySQL with it's semicolons?

Maybe this:
$online = "INSERT INTO xtwf_online (uname, place) VALUES ('$user', 'Just logged in' );";
mysql_query( $online );
 

DearHeart

Expert Member
Joined
Jun 22, 2005
Messages
1,423
Why '$user' (string)? and not just $user (variable)? Except if it is some advanced technique I'm not aware of ;)

PS Posted: 19-08-2009, 12:05 AM - There's your problem!
 
Last edited:

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
Why '$user' (string)? and not just $user (variable)? Except if it is some advanced technique I'm not aware of ;)

PS Posted: 19-08-2009, 12:05 AM - There's your problem!

Oh I see what you're saying he should have something like
$online = "INSERT INTO xtwf_online (uname, place) VALUES ('" + $user +"', 'Just logged in' );";
mysql_query( $online );

Maybe someone can post the paramaterised version of this, me no speak PHP.
 

James

Expert Member
Joined
May 26, 2004
Messages
2,617
Code:
$online = "INSERT INTO xtwf_online (uname, place) VALUES ('".mysql_real_escape_string($user)."', 'Just logged in' )";

$r = mysql_query($online, [i]insert DB resource here[/i] );
 

DearHeart

Expert Member
Joined
Jun 22, 2005
Messages
1,423
Ya, I'm dreaming... Just woke up with your post! This should do with "." instead of the "+" concatenation.
 

DearHeart

Expert Member
Joined
Jun 22, 2005
Messages
1,423
Hehehe.... matrixweb, when you eventually wake up, look in the php_error.log or run the script through phpMyAdmin, should tell you what's wrong ;0)
 
Top