PDA

View Full Version : Help comparing a table value to a variable


PlymWS
02-27-2008, 12:26 PM
I am trying to get a value from the VB database and compare it to a string submitted in a form.

The custom form takes an input from a form ($name). I want to compare $name, which will be an alphanumerical string, to userfield.field3 which is also an alphanum.

I have tried the following code but I get Resource id #18 instead of the actual value stored in the DB.

$name2 = $db->query_read("SELECT field3 FROM " . TABLE_PREFIX . "userfield WHERE userid = " . $vbulletin->userinfo['userid'] );

if $name !== $name2 {

do something; }

This doesn't work. I'm assuming I'm doing the SQL part wrong. Can someone put me right please.

Opserty
02-27-2008, 01:49 PM
If this is on a vBulletin page, you don't need to run any queries...


if($vbulletin->userinfo['field3'] == $name)
{
// Do something
}

PlymWS
02-27-2008, 09:55 PM
I knew this would be an easy solution !! Thanks !