Jump to content

[SOLVED] no user with id echo


runnerjp

Recommended Posts

ah... ok now i get anouther error lol why does 1 error lead to more lol

 

<?php
  session_start();
  require_once '../settings.php';
  $query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1"; 

  if ($result = mysql_query($query)) {
    if (mysql_num_rows($result)) { 
      $array = mysql_fetch_assoc($result);
      $pemail = $array['Email'];
      $puser = $array['Username'];
  	$pid = $array['ID'];		
		$sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1"; 
		$q = mysql_query($sql) or die("Error running query:".mysql_error());

		if($q && mysql_num_rows($q) > 0){
  				$row = mysql_fetch_array($q);

							 if(!empty($row)){
    							echo "<img src='http://www.runningprofiles.com/members/images/". $pid . "." . $row['ext']  . "' />";
  						}
	}
else {

  echo '<img src="images/pic.jpg">';
  	}
} 
{
echo '<table width="100%">

  <tr>

    <td colspan="3"><div align="center">Welcome to '.$puser.'\'s profile</div></td>

  </tr>

  <tr>

    <td width="162">your id is no '.$puser.'</td>

    <td width="711"></td>

    <td width="100">

  </td>

  </tr>

</table>';


else {
      echo "No users found with id $id<br />";
    }
  } 

 

Parse error: syntax error, unexpected T_ELSE in /home/runningp/public_html/members/profile.php on line 51  else {

      echo "No users found with id $id<br />";

<?php
  session_start();
  require_once '../settings.php';
  $query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1"; 

  if ($result = mysql_query($query)) {
    if (mysql_num_rows($result)) { 
      $array = mysql_fetch_assoc($result);
      $pemail = $array['Email'];
      $puser = $array['Username'];
  	$pid = $array['ID'];		
		$sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1"; 
		$q = mysql_query($sql) or die("Error running query:".mysql_error());

		if($q && mysql_num_rows($q) > 0){
  				$row = mysql_fetch_array($q);

							 if(!empty($row)){
    							echo "<img src='http://www.runningprofiles.com/members/images/". $pid . "." . $row['ext']  . "' />";
  						}
	}
else {

  echo '<img src="images/pic.jpg">';
  	}
} 
{
echo '<table width="100%">

  <tr>

    <td colspan="3"><div align="center">Welcome to '.$puser.'\'s profile</div></td>

  </tr>

  <tr>

    <td width="162">your id is no '.$puser.'</td>

    <td width="711"></td>

    <td width="100">

  </td>

  </tr>

</table>';
}
else {
      echo "No users found with id $id<br />";
    }
  } 
else {
    echo "Query failed<br />$sql<br />" . mysql_error();
  }
}
  ?>

 

 

full code

hey guys... why will this not work??

 

echo '<table width="100%">
        
          <tr>
        
            <td colspan="3"><div align="center">Welcome to '.$puser.'\'s profile</div></td>
        
          </tr>
        
          <tr>
        
            <td width="162">your id is no '.$pid.'</td>
        
            <td width="711"> $q = mysql_query($sql) or die("Error running query:".mysql_error());

        if($q && mysql_num_rows($q) > 0)
        {
            $row = mysql_fetch_array($q);
            if(!empty($row))
                echo "<img src='http://www.runningprofiles.com/members/images/". $pid . "." . $row['ext']  . "' />";
        }
        else
        {
            echo '<img src="images/pic.jpg">';</td>
        
            <td width="100">

sorry i cant add code into table like so

 

<?php
session_start();
require_once '../settings.php';
$query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1"; 

if ($result = mysql_query($query))
{
    if (mysql_num_rows($result))
    { 
        $array = mysql_fetch_assoc($result);
        $pemail = $array['Email'];
        $puser = $array['Username'];
        $pid = $array['ID'];        
        $sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1"; 
       
        }
        echo '<table width="100%">
        
          <tr>
        
            <td colspan="3"><div align="center">Welcome to '.$puser.'\'s profile</div></td>
        
          </tr>
        
          <tr>
        
            <td width="162">your id is no '.$pid.'</td>
        
            <td width="711"> $q = mysql_query($sql) or die("Error running query:".mysql_error());

        if($q && mysql_num_rows($q) > 0)
        {
            $row = mysql_fetch_array($q);
            if(!empty($row))
                echo "<img src='http://www.runningprofiles.com/members/images/". $pid . "." . $row['ext']  . "' />";
        }
        else
        {
            echo '<img src="images/pic.jpg">';</td>
        
            <td width="100">
        
          </td>
        
          </tr>
        
        </table>
        ';

     }
    else
    {
        echo "No users found with id $id<br />";
    }
} 
else
{
    echo "Query failed<br />$sql<br />" . mysql_error();
}
?> 

You are better off doing it the opposite way, turn PHP off, do your HTML, then turn PHP back on when you want code.  As it is now, you are not using your quotes right so your data is getting messed up.

 

Like this line

 

echo "<img src='http://www.runningprofiles.com/members/images/".

 

you used a single quote there and you needed to escape it.

 

Check this for errors but it should be close

 

<?php
session_start();
require_once '../settings.php';
$query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1"; 

if ($result = mysql_query($query)){

    if (mysql_num_rows($result)) {

        $array = mysql_fetch_assoc($result);
        $pemail = $array['Email'];
        $puser = $array['Username'];
        $pid = $array['ID'];        
        $sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1"; 
       ?>
        <table width="100%">      
          <tr>     
            <td colspan="3"><div align="center">Welcome to <?php echo $puser; ?>'s profile</td>       
          </tr>        
          <tr>        
           <td width="162">your id is no <?php echo $pid; ?></td>        
           <td width="711"><?php $q = mysql_query($sql) or die("Error running query:".mysql_error());
       				 if($q && mysql_num_rows($q) > 0)  {
            		$row = mysql_fetch_array($q);
            		if(!empty($row)) {
                	echo "<img src=\"http://www.runningprofiles.com/members/images/$pid.$row['ext']\" />";
       					 	}
        					else {
            			echo '<img src="images/pic.jpg">';
								}
							}
							?></td>       
            	<td width="100">    
              </td>
          	</tr>        
        </table>
<?php
     }
    else
    {
        echo "No users found with id $id<br />";
    }
} 
else
{
    echo "Query failed<br />$sql<br />" . mysql_error();
}
?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.