Web Analytics Made Easy -
StatCounter Problem with query - CodingForum

Announcement

Collapse
No announcement yet.

Problem with query

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with query

    Hiya. I am trying to query my database by the COOKIE variable and then display the data for that use below. But it does not seem to be working, all i am getting is the white page which suggests there is a syntax error, but i cant see any problem? can anybody help?
    Thanks.

    Code:
    <?php
    			
    			error_reporting(E_ALL);
    
    			include ('connect.php'); 
    			mysql_select_db("a6188092") or die(mysql_error());
    
    			if (isset ($_COOKIE['loginName']))
    			{
    				$query = mysql_query(sprintf("SELECT * FROM Member WHERE loginName='%s'", mysql_real_escape_string(trim($_COOKIE['loginName'])))) or die ('SQL Error: ' . mysql_error());
    
    				if (mysql_num_rows($query) > 0)
    				{
    					while ($row = mysql_fetch_array($query)) 
    					{
    						echo '<p>User name : '.$row['loginName']).'</p>'; 
    						echo '<p>Email : '.$row['email']).'</p>';
    						echo '<p>First name : '.$row['firstName']).'</p>';
    						echo '<p>User name : '.$row['surname']).'</p>';
    					}
    				} 
    				else 
    				{
    					echo 'no results found.';
    				}
    			} 
    			else 
    			{
    				echo 'name isnt set.';
    			}
    			?>

  • #2
    PHP Code:
    <?php
                
                error_reporting
    (E_ALL);

                include (
    'connect.php'); 
                
    mysql_select_db("a6188092") or die(mysql_error());

                if (isset (
    $_COOKIE['loginName']))
                {
                    
    $query mysql_query(sprintf("SELECT * FROM Member WHERE loginName='%s'"mysql_real_escape_string(trim($_COOKIE['loginName'])))) or die ('SQL Error: ' mysql_error());

                    if (
    mysql_num_rows($query) > 0)
                    {
                        while (
    $row mysql_fetch_array($query)) 
                        {
                            echo 
    '<p>User name : '.$row['loginName'].'</p>'
                            echo 
    '<p>Email : '.$row['email'].'</p>';
                            echo 
    '<p>First name : '.$row['firstName'].'</p>';
                            echo 
    '<p>User name : '.$row['surname'].'</p>';
                        }
                    } 
                    else 
                    {
                        echo 
    'no results found.';
                    }
                } 
                else 
                {
                    echo 
    'name isnt set.';
                }
                
    ?>
    Twitter: @AnthonySterling

    Comment

    Working...
    X