PDA

View Full Version : showing content on page if logged in


runnerjp
12-08-2007, 10:29 PM
hey guys im trying 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">';
}
}
{
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();
}

?>

but get Parse error: syntax error, unexpected $end in /home/runningp/public_html/members/profile.php on line 59

Inigoesdr
12-08-2007, 11:16 PM
Use tags when you post code
Indent your code so you can catch mistakes easier
Get an IDE with syntax highlighting and error checking


<?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();
}
?>
The error was caused by you not closing your long echo() in the middle, but you had several other errors like unmatched brackets and missing else's.

runnerjp
12-08-2007, 11:23 PM
hey ty for that :)

can i ask
Get an IDE with syntax highlighting and error checking

where can i fidn these?

Inigoesdr
12-08-2007, 11:30 PM
http://mashable.com/2007/11/17/ide-toolbox/

runnerjp
12-09-2007, 11:22 AM
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">

Inigoesdr
12-09-2007, 08:12 PM
Because you did.. the same thing I just told you to fix.
The error was caused by you not closing your long echo()

runnerjp
12-10-2007, 12:38 PM
oh no i found lots of errors.. but managed to fix them ty

ahallicks
12-10-2007, 01:47 PM
Irony... when you used the [php] tags it showed up the error!

aedrin
12-10-2007, 05:14 PM
http://mashable.com/2007/11/17/ide-toolbox/

I thought this was somewhat funny:


Dev-PHP - Dev-PHP is a fully featured development IDE for PHP. It is open-source, runs on windows and features: class browser, scripts preview, integration with PHP parsers, PHP-GTK library, and Xdebug of course.

Eclipse PHP IDE - An open source PHP IDE project from Eclipse.


Seems a little biased, considering Eclipse does all those things and probably more. Not to mention you can also develop many other languages in Eclipse, so you don't have to install and learn multiple IDEs.

kingtas
12-10-2007, 06:05 PM
HTML-Kit FTW. :thumbsup:

Inigoesdr
12-10-2007, 09:50 PM
Seems a little biased, considering Eclipse does all those things and probably more. Not to mention you can also develop many other languages in Eclipse, so you don't have to install and learn multiple IDEs.

Yeah, the descriptions are obviously biased. I use phpDesigner personally. I think you've said you use Eclipse before, right? I tried it some time ago, but the version I tried was very bloated. Maybe it's better now. :D

aedrin
12-10-2007, 10:05 PM
I think you've said you use Eclipse before, right? I tried it some time ago, but the version I tried was very bloated.

Yeah, I do use it.

It probably is a little bit bloated. But that's why I like it, because it's bloated with other languages (Java, etc.) which I use daily. So rather than having 2 environments I just need one. Not to mention that I like the reuse of IDEs rather than everyone developing their own.