www.webdeveloper.com
Results 1 to 8 of 8

Thread: simple parse error but i cant debug it

  1. #1
    Join Date
    Feb 2003
    Location
    UK
    Posts
    190

    simple parse error but i cant debug it

    I keep getting a parse error on the following line:

    PHP Code:
    while($row mysql_fetch_array['result']) 
    I downloaded the script (i cant remember where from now) but I have been trying to alter to to get it to work, but I'm not the usuage of
    PHP Code:
    mysql_fetch_array['result'
    like that before

    PHP Code:

    <?

    include"settings.php"


    if (isset(
    $submit)) // name of submit button
    $query "select * from logintable where username='$username' and password='$password'"
    echo 
    "\n\nQuery:".$query;

    $result mysql_query($query); 
    echo 
    "\n\nResult:".$result;
    $isAuth false//set to false originally

    while($row mysql_fetch_array['result'])
    {
    echo 
    $row['username'];
    echo 
    $row['password'];
    if(
    $row['username'] == $username
    //above row checks to see if username/password combination exists 

    $isAuth true
    session_start();
    session_register('username');


    if(
    $isAuth)
    {
    print 
    "logged in successfully<br>";
    print 
    "<A href='index.php'>Go to Admin Panel</a>";
    }
    else
    //if login/pass does not exist 
    {
    print 
    "Wrong username or password";
    }
    }
    ?>
    Or if anyone can direct me to simple easy to use login script for admin system it would be greatly appreciated,

    thanks Neil

  2. #2
    Join Date
    Mar 2004
    Location
    London, UK
    Posts
    342
    mysql_fetch_array is a function.

    So...

    PHP Code:
    mysql_fetch_array['result'];

    is wrong.  It implies that mysql_fetch_array is an array not a function. 
    ... it must be

    PHP Code:
    mysql_fetch_array($result);

    function uses round bracketsnot square ones

  3. #3
    Join Date
    Feb 2003
    Location
    UK
    Posts
    190
    thats what i thought about the function,

    but i got confused as to whether it was right or not because when i change it to
    PHP Code:
    while($row mysql_fetch_array($result)) 
    i get the following error messages

    form submitted Query:select * from logintable where username='username' and password='password' Warning: Access denied for user: 'urbanaca@localhost' (Using password: NO) in /home/urbanaca/public_html/test/authenticate.php on line 21 Warning: MySQL Connection Failed: Access denied for user: 'urbanaca@localhost' (Using password: NO) in /home/urbanaca/public_html/test/authenticate.php on line 21 Warning: MySQL: A link to the server could not be established in /home/urbanaca/public_html/test/authenticate.php on line 21 Result: Warning: Supplied argument is not a valid MySQL result resource in /home/urbanaca/public_html/test/authenticate.php on line 25 Wrong username or password

  4. #4
    Join Date
    Mar 2004
    Location
    London, UK
    Posts
    342
    Check the connection string in your settings.php, ie username and password to connect to the database.

  5. #5
    Join Date
    Feb 2003
    Location
    UK
    Posts
    190
    i'm trying that,

    but unless I'm mistaken the correct name/pass are not working? ??

  6. #6
    Join Date
    Feb 2003
    Location
    UK
    Posts
    190
    I've used some different connection code from another file i had work and I don't get the errors now, but i've got a different problem which i will post if it continues to prove a problem

  7. #7
    Join Date
    Feb 2003
    Location
    UK
    Posts
    190
    the code is now like this

    The connection info is all correct, when i test the sql in php admin it is fine,

    but i think it gives false for while($row = mysql_fetch_array($result))
    doesn't go into the while loop and goes straight into print "Wrong username or password"; because $auth is false

    any idead anyone?

    Cheers Neil


    PHP Code:

    <?

    # PULL ADDITIONAL FILES
    include_once (".././settings.php");
    # CONNECT TO THE MySQL SERVER
    $link mysql_connect($host,$user,$password);
    # SELECT THE DATABASE NEEDED
    mysql_select_db("$base");


    if (isset(
    $submit)) // name of submit button

    echo 
    "form submitted\n\n";
    $query "select * from logintable where username='$username' and password='$password'"
    echo 
    "\t\tQuery:".$query;
     
    // $db = mysql_pconnect($dbHost, $dbUser, $dbPass);
     // mysql_select_db($dbName, $db);
    $result mysql_query($query);
    //echo "\t\tResult:".$result;
    $isAuth false//set to false originally

    while($row mysql_fetch_array($result))
    {
    //echo $row['username'];
    //echo $row['password'];
    if($row['username'] == $username
    //above row checks to see if username/password combination exists 

    $isAuth true
    session_start();
    session_register('username');


    if(
    $isAuth)
    {
    print 
    "logged in successfully<br>";
    print 
    "<A href='index.php'>Go to Admin Panel</a>";
    }
    else
    //if login/pass does not exist 
    {
    print 
    "Wrong username or password";
    }
    }
    ?>

  8. #8
    Join Date
    Feb 2003
    Location
    UK
    Posts
    190
    I just realised an include used a same variable name as one submitted by the form

    but with having this before echoes causes the error "msg headers already sent" , any ideas whats that about?

    session_start();

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles