Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP & MYSQL basic question

  • 13-01-2006 11:47AM
    #1
    Registered Users, Registered Users 2 Posts: 148 ✭✭


    I have this code, it's been working before, not sure what happened it could not connect now :confused: ! ! !

    $user = "user1";
    $host = "localhost";
    $password = "pass1";
    $database = "data1";
    $connection = mysql_connect($host,$user,$password)
    or die ("Error 1");
    $db = mysql_select_db($database, $connection)
    or die ("Error2");

    $query = "Select email from passfile where email = '$emailkey' and PASSWORD = $pass";
    $result = mysql_query($query)
    or die ("Error 3");
    $num = mysql_num_rows($result);


    It display's Error 3. It managed to pass Error 1 & Error 2, but I am sure I have given user 1 proper authority . . .

    Anyone, please . . . .


Comments

  • Registered Users, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    Use
    die("Error 3: ".mysql_error());
    

    This will print out a reason why you got an error.


  • Registered Users, Registered Users 2 Posts: 2,472 ✭✭✭Sposs


    have you change the password on the database without updating your php script?

    That's a fairly common reason.But hard to tell without more info.

    What error message are you getting?


  • Moderators, Politics Moderators, Paid Member Posts: 44,329 Mod ✭✭✭✭Seth Brundle


    Is there a table called passfile with columns called email and PASSWORD?

    Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/ .



  • Registered Users, Registered Users 2 Posts: 148 ✭✭maco


    Thanks for the replies . . . .
    First, i have not changed the password, If I am not wrong it should fail right away in Error 1.

    Second, email and PASSWORD are found in PASS file.

    I have chage the the error message to ("Error 3: ".mysql_error()); as suggested,

    the funny thing is,

    if my input is email = 1234 and password = 1234, it works, it shows the proper error saying emial 1234 does not exist

    But if my input is email = abcd and password = abcd, it does not works, it shows error 3 with an sql error of Unknown column 'abcd' in 'where clause'

    My email setting is 50 varchar, not sure what tot do next . . .


  • Closed Accounts Posts: 7,144 ✭✭✭DonkeyStyle \o/


    maco wrote:
    the funny thing is,

    if my input is email = 1234 and password = 1234, it works, it shows the proper error saying emial 1234 does not exist

    But if my input is email = abcd and password = abcd, it does not works, it shows error 3 with an sql error of Unknown column 'abcd' in 'where clause'
    I'd enclose that $pass in quotes tbh... afaik mysql is alright with int's not having quotes but not chars, which is why you get away with 1234, but not abcd.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 148 ✭✭maco


    spot on !!! :D

    thanks to all of you ..........


Advertisement