Thread: PHP Small error[PLEASE READ]

Results 1 to 6 of 6
  1. #1 PHP Small error[PLEASE READ] 
    Registered Member
    Join Date
    Oct 2011
    Posts
    56
    Thanks given
    0
    Thanks received
    1
    Rep Power
    44
    Hey guys, I am currently creating a website and I am having some trouble, here is my problem
    Code:
    Parse error: syntax error, unexpected ';' in /home/a1558487/public_html/VisualUpload/func/user.func.php on line 10
    and here is the file
    Code:
    <?php
    
    function logged_in()	{
    return isset($_SESSION['user_id']);
    
    }
    
    function login_check($email, $password)	{
    $email = mysql_real_escape_string($email);
    $login_query = mysql_query("SELECT COUNT('user_id') as 'count', 'user_id' FROM 'users' WHERE 'email'='$email' AND 'password'='".md5($password."'");
    return (mysql_result($login_query, 0) == 1) ? mysql_result($login_query, 0, 'user_id') : false;
    
    }
    
    function user_data()	{
    $args = func_get_args();
    $fields = '`'.implode('`, ', $args).'`';
    
    $query = mysql_query("SELECT $fields FROM 'users' WHERE 'user_id'=".$_SESSION['user_id']);
    $query_result = mysql_fetch_assoc($query);
    foreach ($args as $field)	{
    $args[$field] = $query_result[$field];
    
    }
    return $args;
    }
    
    function user_register($email, $name, $password)	{
    $email = mysql_real_escape_string($email);
    $name = mysql_real_escape_string($name);
    mysql_query("INSERT INTO 'users' VALUES ('', '$email', '$name', '".md5($password)."')");
    return mysql_insert_id();
    
    }
    
    function user_exists($email)	{
    $email = mysql_real_escape_string($email);
    $query = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'email'='$email'");
    return (mysql_result($query, 0) == 1) ? true : false;
    
    }
    
    ?>
    I hope someone can please help
    Reply With Quote  
     

  2. #2  
    Registered Member
    Ant-Man's Avatar
    Join Date
    Aug 2010
    Posts
    1,018
    Thanks given
    277
    Thanks received
    177
    Rep Power
    452
    Code:
    $login_query = mysql_query("SELECT COUNT('user_id') as 'count', 'user_id' FROM 'users' WHERE 'email'='$email' AND 'password'='".md5($password."'"));
    Fixes your error, didn't look over the rest though.

    But my God... you don't need to bump the topic ever 10min, not like this section gets much attention anyways.

    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Oct 2011
    Posts
    56
    Thanks given
    0
    Thanks received
    1
    Rep Power
    44
    Now I have this error

    Code:
    Parse error: syntax error, unexpected T_STRING in /home/a1558487/public_html/VisualUpload/widgets/menu.php on line 4
    file
    Code:
    <a href='index.php'>Home</a>
    
    <?php
    if (logged in());
    ?>
    
    <a href='register.php'>Register</a>
    
    <?php
    } else {
    ?>
    
    <a href="logout.php">Logout</a> /
    <a href="create_album.php">Create Album</a> /
    <a href="albums.php">My Albums</a>
    
    <?php
    }
    ?>
    Reply With Quote  
     

  4. #4  
    Boom Boom

    Kakapo's Avatar
    Join Date
    Aug 2010
    Posts
    1,030
    Thanks given
    358
    Thanks received
    218
    Rep Power
    365
    Theres no bracket here:
    Code:
    <?php
    if (!logged in()) {
    ?>
    But you're using this as if there were:

    Code:
    <?php
    } else {
    ?>
    Also, Why do you want it to show the register button if they're logged in? I think you meant to have:

    Code:
    <?php
    if (!logged in()) {
    ?>
    Anyway its fixed

    Code:
    <a href='index.php'>Home</a>
    
    <?php
    if (logged in()) {
    ?>
    
    <a href='register.php'>Register</a>
    
    <?php
    } else {
    ?>
    
    <a href="logout.php">Logout</a> /
    <a href="create_album.php">Create Album</a> /
    <a href="albums.php">My Albums</a>
    
    <?php
    }
    ?>


    Reply With Quote  
     

  5. #5  
    Registered Member
    Anthony`'s Avatar
    Join Date
    Sep 2008
    Age
    29
    Posts
    763
    Thanks given
    75
    Thanks received
    164
    Rep Power
    204
    ^ is_logged()*?
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Oct 2011
    Posts
    56
    Thanks given
    0
    Thanks received
    1
    Rep Power
    44
    You didn't fix it Kakapo, I figured it out, it was meant to be like this

    Code:
    <?php
    if (logged in()) {
    header('Location: index.php');
    exit();
    }
    ?>
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. [PI] Another small error :fp:
    By Rev3rt in forum Help
    Replies: 25
    Last Post: 08-27-2011, 12:38 PM
  2. small 100 error help
    By Ta1nt3d in forum Help
    Replies: 4
    Last Post: 07-11-2011, 03:01 AM
  3. Small Error
    By Effection in forum Help
    Replies: 0
    Last Post: 10-18-2010, 11:27 PM
  4. Small error?
    By M,i,K,e_ in forum Help
    Replies: 8
    Last Post: 04-10-2009, 10:10 AM
  5. i need some small help 1 error
    By Santaher0 in forum Help
    Replies: 6
    Last Post: 03-22-2009, 09:52 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
  •