...

View Full Version : script to show images in my message :P



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&#37;" 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?

PappaJohn
05-17-2008, 08:07 PM
$sql = "SELECT t.*,user_images.ext as ext,users.ID as pid as `ext`
You can't assign two column names to the alias.

runnerjp
05-17-2008, 10:01 PM
ok i bailed on that idea i was getting to confused at what coloums whent wherre ect lol gonna go for long widned version


<?
session_start();
require_once '../../settings.php';
require ("required.php");

echo "<!-- $scriptname v$version Start -->\n\n";
echo "<HTML>\n";
echo " <HEAD>\n";
echo " <LINK rel=\"stylesheet\" type=\"text/css\" href=\"shoutbox/tagboard.css\">\n";
echo " </HEAD>\n";
echo " <BODY topmargin=\"2\" leftmargin=\"2\" bottommargin=\"2\" rightmargin=\"2\">\n";
$user2 = $_GET['username'];
if ($usemysql == 1)
{
/* Load the tagboard, the X number of most recent posts */
if ($order == "0")

$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.runningprofiles.com/members/images/mini/". $pid . "." . $row['ext'] . "'";
}
else {
echo 'no image';
}

















































}
?> </td>
<td width="99%" bgcolor="#e4ebeb"><?php echo $nick;?> wrote</td>
</tr>
<tr>
<td bgcolor="#e4ebeb">at <? echo $senton;?></td>
</tr>
<tr>
<td><? echo $msg;?></td>
</tr>

</table>
<BR>



<?
}










/* Like always, we close the connection to the database */
mysql_close($connection);
}
else
{
$i = 0;
$file_lines = file($flatfile);

foreach($file_lines as $line)
{
if ($i <= $howmany)
{
$delim = strpos($line, "%%");
$ts_delim = strpos($line, "@@");
$ip_delim = strpos($line, "##");

$nick = substr($line, 0, $delim);
$message = substr($line, $delim + 2, $ts_delim - $delim - 2);
$ts = substr($line, $ts_delim + 2, $ip_delim - $ts_delim - 2);

if ($timestamping == 1)
echo " <B>$nick ($ts)$spacer</B> ";
else
echo " <B>$nick$spacer</B> ";

if ($emoticon == 1)
echo (emoticon($message));



echo "<BR>\n";

$i++;
}
}
}



function emoticon($msg)
{
$msg = str_replace("o:-)", "<IMG src=\"http://www.r.com/members/shoutbox/images/angel.gif\">", $msg);

return $msg;
}

?>

the problem is my images are not being shown :S i think i have put a } in the wrong place but im not sure...

runnerjp
05-17-2008, 10:44 PM
<?php $sql = "SELECT t.*,user_images.ext as ext,users.ID as pid FROM $tablname as t,users,user_images WHERE t.account = '$user2' AND t.nick=nick AND users.ID = user_images.user_id ORDER BY t.id DESC LIMIT 10";
$result = mysql_db_query($database,$sql,$connection) or die(mysql_error().'<br />Query was:'.$sql);
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);
$id = $row['pid'];
$ext = $row['ext'];
//echo out as required
?>




where it says ORDER BY t.id DESC LIMIT 10 well for some reason its only displaying 1 message rather then 10 :S

would look like this <?php $SQL = "SELECT * FROM $tablname WHERE account = '$user2' ORDER BY id DESC LIMIT 10";?>




also... the image is not displaying for the right person... what i need it to be is that $nick = username in the table users... so what parts do i need to chnage for that..iv had ago but keep getting errors



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum