runnerjp
05-17-2008, 06:45 PM
hey guys...im getting You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as `ext` FROM tagboard as t,users,photos WHERE t.account = 'Admin' AND t.nick=us' at line 1 $sql = "SELECT t.*,user_images.ext as ext,users.ID as pid as `ext` FROM $tablname as t,users,photos WHERE t.account = '$user2' AND t.nick=users.ID AND users.ID = user_images.user_id ORDER BY t.id DESC LIMIT $howmany";
$result = mysql_db_query($database,$sql,$connection) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$nick = $row["nick"];
$url = $row["url"];
$message = $row["message"];
$datetime = $row["datetime"];
$senton= date("M jS, Y \a\\t h:i A T", $datetime);
$pid = $row['pid'];
$ext = $row['ext'];
//echo out as required
}
not sure where... this is 1st time im using the combind querying... mine used to look like this
<?php $SQL = "SELECT * FROM $tablname WHERE account = '$user2' ORDER BY id DESC LIMIT $howmany";
$results = mysql_db_query($database, "$SQL", $connection);
if (!$results)
return ("ERROR: " . mysql_error() . "\n$SQL\n");
while ($row = mysql_fetch_array($results))
{
$nick = $row["nick"];
$url = $row["url"];
$message = $row["message"];
$datetime = $row["datetime"];
$senton= date("M jS, Y \a\\t h:i A T", $datetime);
/* Add Emoticons to the user's message */
if ($emoticon == 1)
$msg = emoticon($message);
/* Some people don't have web sites, so we check to see if they put a URL in the database */
if ($url=="" or $url=="http://") /* If they didn't then we just display the nick and the message */
$nick = "$nick";
else /* If they did, then we link it!! */
$nick = "<a href=\"$url\" target=\"_blank\">$nick</a>";
$query = "SELECT * FROM users WHERE Username = '$nick' LIMIT 1";
if ($result = mysql_query($query)or die("Error running query:".mysql_error())){
if (mysql_num_rows($result)) {
$array = mysql_fetch_assoc($result);
$pid = $array['ID'];
$sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1";?>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="1%" rowspan="3" align="left" valign="top"><?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.website.com/members/images/mini/". $pid . "." . $row['ext'] . "'";
}
else {
echo 'no image';
}
}
?>
im i doing it right?
$result = mysql_db_query($database,$sql,$connection) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$nick = $row["nick"];
$url = $row["url"];
$message = $row["message"];
$datetime = $row["datetime"];
$senton= date("M jS, Y \a\\t h:i A T", $datetime);
$pid = $row['pid'];
$ext = $row['ext'];
//echo out as required
}
not sure where... this is 1st time im using the combind querying... mine used to look like this
<?php $SQL = "SELECT * FROM $tablname WHERE account = '$user2' ORDER BY id DESC LIMIT $howmany";
$results = mysql_db_query($database, "$SQL", $connection);
if (!$results)
return ("ERROR: " . mysql_error() . "\n$SQL\n");
while ($row = mysql_fetch_array($results))
{
$nick = $row["nick"];
$url = $row["url"];
$message = $row["message"];
$datetime = $row["datetime"];
$senton= date("M jS, Y \a\\t h:i A T", $datetime);
/* Add Emoticons to the user's message */
if ($emoticon == 1)
$msg = emoticon($message);
/* Some people don't have web sites, so we check to see if they put a URL in the database */
if ($url=="" or $url=="http://") /* If they didn't then we just display the nick and the message */
$nick = "$nick";
else /* If they did, then we link it!! */
$nick = "<a href=\"$url\" target=\"_blank\">$nick</a>";
$query = "SELECT * FROM users WHERE Username = '$nick' LIMIT 1";
if ($result = mysql_query($query)or die("Error running query:".mysql_error())){
if (mysql_num_rows($result)) {
$array = mysql_fetch_assoc($result);
$pid = $array['ID'];
$sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1";?>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="1%" rowspan="3" align="left" valign="top"><?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.website.com/members/images/mini/". $pid . "." . $row['ext'] . "'";
}
else {
echo 'no image';
}
}
?>
im i doing it right?