Results 1 to 7 of 7
  1. #1
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    PHP fetch problem! Please help!
    I am using this to fetch and compare if 'userid' exists and match in a database. If it matches, it works. But how come if it doesn't match, I get a blank page load? Any help wold be greatly appreciated. btw, if it doesn't match, I want to echo 'User ID does not match'.

    if (!($link = mysql_connect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD))) {
    echo "could not connect to database";
    exit();
    }

    if (!($result = mysql_db_query($DB, "select userid from wb_auth where userid='$userid'"))) {
    echo "could not run query";
    exit();
    }

    while ($row=mysql_fetch_array($result)){

    echo "Here is your ID: $row[userid]";

    }

  2. #2
    Not Verif-Lidated infoTim's Avatar
    Join Date
    January 18th, 2005
    Location
    Sunny Florida
    Posts
    1,021
    If it doesn't match, it's going to go all the way through the loop at the end without printing anything, which is what it sounds like it's doing. I'm a PostgreSQL junkie these days so it's been a while since I've used mySQL, but I think you could put this in front of the while:

    if (mysql_num_rows($result)==0) {
    echo "User ID does not match";
    }
    else
    while ...
    Tim
    consultant by day, affiliate by night

  3. #3
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    PERFECT! It worked! Thanks a million, this has been driving me nuts for 24 hrs now. Thanks again infospongellc!

  4. #4
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    ok spoke too soon. It no longer works. What the? When I run this, it can find the userid:

    ****
    if (!($link = mysql_connect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD))) {
    echo "could not connect to database";
    exit();
    }

    if (!($result = mysql_db_query($DB, "select userid from wb_auth where userid='$userid'"))) {
    echo "could not run query";
    exit();
    }
    while ($row=mysql_fetch_array($result)){

    echo "Here is your userid: $row[userid]";
    }
    ****

    When I ran this the first time, it worked. But it always returns User ID does not match? Any ideas?

    ****

    if (!($link = mysql_connect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD))) {
    echo "could not connect to database";
    exit();
    }

    if (mysql_num_rows($result)==0) {
    echo "User ID does not match";
    }
    else
    {
    if (!($result = mysql_db_query($DB, "select userid from wb_auth where userid='$userid'"))) {
    echo "could not run query";
    exit();
    }
    while ($row=mysql_fetch_array($result)){

    echo "Here is your userid: $row[userid]";
    }
    }

    ****

  5. #5
    Newbie
    Join Date
    January 18th, 2005
    Posts
    36
    PHP fetch problem! Please help!
    Hi

    You have to do
    $result = mysql_db_query($DB, "select userid from wb_auth where userid='$userid'";

    before you can

    f (mysql_num_rows($result)==0) {
    echo "User ID does not match";
    }

  6. #6
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    ahhh yes, tarev. Thank you. Now it works! Maybe it's time for a break... Thanks again infospongellc & Tarev!

  7. #7
    Newbie
    Join Date
    January 18th, 2005
    Posts
    36
    PHP fetch problem! Please help!
    Allways a pleasure
    --------------------------------
    PHP & Mysql Support
    <a target="_blank" href="http://www.scriptresources.com/?abestweb">
    ScriptResources.com</a>

  8. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. I am Stumped with a PHP/MYSQL problem
    By Uncle Rico in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: August 13th, 2010, 06:19 PM
  2. Php code problem
    By cdunde1 in forum GoldenCAN
    Replies: 9
    Last Post: August 30th, 2008, 04:55 AM
  3. I have a php problem
    By Gordon in forum Programming / Datafeeds / Tools
    Replies: 6
    Last Post: March 11th, 2004, 04:58 AM
  4. Problem running PHP
    By frank3iii in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: July 7th, 2003, 11:11 PM
  5. ae.pl -- PHP Virtual problem
    By rardentech in forum Cusimano.com Scripts
    Replies: 5
    Last Post: June 28th, 2003, 05:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •