View Full Version : Calling from mysql to echo error

03-26-2009, 06:48 AM

On the right side of my page im trying to get the script to echo the clicks for the image. The echo works in the description. Please look at my right side to see if you can pinpoint any coding errors.

<h5>Number of Clicks</h5></i><? echo mysql_result($yy,0,"img_clicked"); ?></td></td>'; is where i am calling the echo

<table border="0">

$query="select * from wp_imgManager_images where img_isapproved='Y' ORDER BY img_clicked DESC";
$dd="select * from wp_imgManager_images where id='".$imgid."'";
echo '<tr>';


echo '</tr><tr>';
$qq="select cat_virt_path from wp_imgManager_categories where id='".$icatid."'";
//echo $qq;
echo '<td width="110" align="center"><a href="?page=images&imgid='.mysql_result($result,$i,"id").'"><img width="100" height="100" src="'.$imgPath.'"></a><i><h5>Number of Clicks</h5></i><? echo mysql_result($yy,0,"img_clicked"); ?></td></td>';
echo '<td>No latest images</td></tr>';
echo '</tr><tr><td colspan=3 align="right"><a href="?page=images">more..</a></td></tr>';
echo "No latest images!!";



03-26-2009, 07:28 AM
Not even sure of what all is going on in this script. It appears as though you have 3 query calls to the database? One of which is inside this loop?

Please, please, please refactor your code using a proper JOIN statement (http://www.lmgtfy.com?q="SQL+JOIN+tutorial"). Also, don't use a for() loop with the mysql_result() function. Ideally this can all be distilled into a single SQL statement / query call, and a simple while() loop utilizing one of the mysql_fetch_* functions (mysql_fetch_assoc() being the preferred choice).

Oh, and the one glaring error I see is that you have an echo statement embedded within another:

<h5>Number of Clicks</h5></i><? echo mysql_result($yy,0,"img_clicked"); ?></td></td>';

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum