Jump to content

[SOLVED] no user with id echo


runnerjp

Recommended Posts

<?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'];

    } else {

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

    }

  } else {

    echo "Query failed<br />$sql<br />" . mysql_error();

  }

$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">';

  }

?>

 

where it says no users with id.. how can i make it so only that comes up as at the moment it shows no users with id but also shows the other information?

Link to comment
Share on other sites

Something like this

 

<?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">';
  	}
} 
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

ah yes buuuuut what if you want to add a table into the mix

 

<?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">';
  	}
} 
else {
      echo "No users found with id $id<br />";
    }
  } 
else {
    echo "Query failed<br />$sql<br />" . mysql_error();
  }
?>



<table width="100%">

  <tr>

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

  </tr>

  <tr>

    <td width="162">your id is no <?echo "$pid"?></td>

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

    <td width="100">

  </td>

  </tr>

</table>

Link to comment
Share on other sites

ok i tried

 

<?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 <?echo "$puser"?>'s profile</div></td>

  </tr>

  <tr>

    <td width="162">your id is no <?echo "$pid"?></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();
  }
  ?>

 

but get unexpected T_STRING, expecting ',' or ';' on line 31

Link to comment
Share on other sites

You are already in PHP since you used Echo so this line isnt valid

 

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

 

you just need

 

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

 

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

 

getting Parse error: syntax error, unexpected T_ELSE, expecting ',' or ';' in /home/runningp/public_html/members/profile.php on line 50

Link to comment
Share on other sites

  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'>;

 

tried it and didnt respond well lol

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.