Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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,317 ✭✭✭✭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 Posts: 41,240 Mod ✭✭✭✭Seth Brundle


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


  • 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,145 ✭✭✭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