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 />";

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

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">

Link to comment
Share on other sites

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();
}
?> 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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();
}
?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.