PDA

View Full Version : checking multiple entries in a db ??


vosgien
07-07-2003, 02:40 PM
Hi,
I am not sure how to go about this, best thing to do is explain, I think first with a little code :

<?
include("connected.php");

$query = "SELECT entryID, password, username FROM $table WHERE email = '$mail'";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
print"&status=".("logon succesful")."&";
exit;
}
else
{
print"&_root.status=".("you are not registered")."&";
exit;
}
/* Close link to MySQL */
mysql_close($link);
?>

The email column is unique, however I want to check the other values are correct as well. How ?
I had thought about writing a $query for each value, which seems a bit long winded to me, can I convert the other values to an array and then check them agains't user input, and if so HOW ?
Anyhow, I will keep trying, in the meantime, any help, pointers etc etc

Cheers

Vosgien

p.s. I think it is one of those things that is probably staring me in the face !!!

tg
07-07-2003, 03:46 PM
try:
"SELECT_entryID,_password,_username_FROM_$table_WHE RE_email_= '$mail' and password='$password' and username='$user";

this will check to see if the username, password and email all match the values in the db.

vosgien
07-07-2003, 03:48 PM
Hi,
Thanks tg, I was just playing around with something similar, tho' it would have taken a while longer to get there I think

Cheers

Vosgien

vosgien
07-07-2003, 04:50 PM
Hi,
I cannot tell if that will work or not as I am getting a parse error, something wrong with my syntax I think.
First of all, I should say that i have narrowed it down to 2 fields that HAVE to be checked, the email addy which is unique and the entryID number which is in fact an invoice number passed to the user after he has paid !
Code is like this :

<?
include("connected.php");

$query = "SELECT entryID, FROM $table WHERE email= '$mail'";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
while($rows = mysql_fetch_array($result))
{
$entryID = $row['entryID'];
print"&status=".("logon succesful")."&";
exit;
}
else
{
print"&_root.status=".("you are not registered")."&";
exit;
}
/* Close link to MySQL */
mysql_close($link);
?>

parese error is 'unexpectedT_ELSE'

What I need to achieve is to check if the email and entryID entered by user are the same as already in the db.

Cheers

Vosgien

tg
07-07-2003, 04:57 PM
i don't know much about php, but is this type of nesting ok?

//
if(mysql_num_rows($result))
{
while($rows_=_mysql_fetch_array($result))
{
$entryID_=_$row['entryID'];
print"&status=".("logon succesful")."&";
exit;
}///this is the end of the while
//place another '}' closing bracket here???
else
{
print"&_root.status=".("you are not registered")."&";
exit;
}

//

ah crap... it removed the spaces i added to show the nesting.


i think you need to add/rearange some of your brackets here somewhere

vosgien
07-07-2003, 05:07 PM
Hi tg,
Yep, that extra brace did the trick in that I am not parseing any errors, now to test the script itself - onward & upward

Bye the bye does anyone know anything about SIM configuration with authorize.net ???

Cheers

Vosgien