revraz Posted December 8, 2007 Share Posted December 8, 2007 Then end ' goes outside the /table tag, not inside. Quote Link to comment 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 />"; Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 8, 2007 Author Share Posted December 8, 2007 </table>'; } did it and didnt work Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 8, 2007 Author Share Posted December 8, 2007 solved tyrevraz for your time Quote Link to comment Share on other sites More sharing options...
revraz Posted December 9, 2007 Share Posted December 9, 2007 Right on Quote Link to comment 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"> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted December 9, 2007 Author Share Posted December 9, 2007 *bump* Quote Link to comment 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. Quote Link to comment 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(); } ?> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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(); } ?> Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.