The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
help selecting from vb3_user table!
Hello,
I know what I am doing (I think!) in PHP but I am having real problems reading the VB3_ tables... This code should check if the username exists in the database, but I cannot get it to work. Can anyone please tell me why? $query = "SELECT * from vb3_user where 1 and username like '$username'"; $result = mysql_query($query); $rows = mysql_num_rows($result); echo $rows; //JUST A TEMPORARY THING FOR TESTING if ($rows>0){ echo('<p><strong><font color="#FF0000">! The username you selected is already being used. Please select another.</font></strong></p>'); } Please note that I already called a connection to the database in an include: $db = mysql_connect("localhost","xxxxx","xxxxx"); mysql_select_db("xxxxx",$db); When I run this script on another table I get back the number of rows through the echo command, but on the vb3_user table I get nothing, not even an 'echo' of $rows (which should be 1 or 0). PLEASE can somebody explain what the hell is happening?!! Regards, Ben. |
#2
|
||||
|
||||
I assume the table name (vb3_user) is correct?
PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
#3
|
|||
|
|||
you get nothing because when there's no result from your query, you should get nothing in your result, and therefore nothing for your rows.
Try using this code instead (also as Kirby said, don't use the 'WHERE 1' and have the 'or die' code) Code:
$query = "SELECT * from vb3_user WHERE username like '$username'"; $result = mysql_query($query) or die('Query not successful: ' . mysql_error()); if ($result){ echo('<p><strong><font color="#FF0000">! The username you selected is already being used. Please select another.</font></strong></p>'); } |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|