revraz Posted December 8, 2007 Share Posted December 8, 2007 Then end ' goes outside the /table tag, not inside. Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-409973 Share on other sites More sharing options...
runnerjp Posted December 8, 2007 Author Share Posted December 8, 2007 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 https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-409991 Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 Because you are missing a } at the end of it like I mentioned twice before Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-409994 Share on other sites More sharing options...
runnerjp Posted December 8, 2007 Author Share Posted December 8, 2007 </table>'; } did it and didnt work Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-409996 Share on other sites More sharing options...
runnerjp Posted December 8, 2007 Author Share Posted December 8, 2007 <?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 https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-409999 Share on other sites More sharing options...
runnerjp Posted December 8, 2007 Author Share Posted December 8, 2007 solved tyrevraz for your time Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410006 Share on other sites More sharing options...
revraz Posted December 9, 2007 Share Posted December 9, 2007 Right on Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410046 Share on other sites More sharing options...
runnerjp Posted December 9, 2007 Author Share Posted December 9, 2007 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 https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410249 Share on other sites More sharing options...
runnerjp Posted December 9, 2007 Author Share Posted December 9, 2007 *bump* Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410302 Share on other sites More sharing options...
revraz Posted December 9, 2007 Share Posted December 9, 2007 You didn't say what wasn't working. Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410320 Share on other sites More sharing options...
runnerjp Posted December 9, 2007 Author Share Posted December 9, 2007 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 https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410356 Share on other sites More sharing options...
revraz Posted December 9, 2007 Share Posted December 9, 2007 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 https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410376 Share on other sites More sharing options...
runnerjp Posted December 9, 2007 Author Share Posted December 9, 2007 could you sho me how cos i dont gt how u can turn php off if a users id is not found Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410379 Share on other sites More sharing options...
revraz Posted December 9, 2007 Share Posted December 9, 2007 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 https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410397 Share on other sites More sharing options...
runnerjp Posted December 9, 2007 Author Share Posted December 9, 2007 doh it was that easy lol fixed errors and workin 100% ty soved! Link to comment https://forums.phpfreaks.com/topic/80782-solved-no-user-with-id-echo/page/2/#findComment-410404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.