How do I initialize a resource id in the mysql_result function. The problem is once the counter reaches 5 it will not reset the index to 0 even though I pass it in as 0 in
$result = mysql_query("SELECT * FROM music where ID='0'",$dbs);
$img = mysql_result($result,0,"image");
This is th.php3
This is the main php script:
Can you please help?
I get the following error message:
before access resulting IMAGE RESULT passing 0 result = Resource id #6
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 6 in /home/sites/site23/web/training/time/t1.php on line 37
$result = mysql_query("SELECT * FROM music where ID='0'",$dbs);
$img = mysql_result($result,0,"image");
This is th.php3
PHP Code:
$hour = 12; //add 3 for eastern time (12 hour format)
$minutes = 28;
$second = 0;
$start_time = mktime((($hour+3)%12), $minutes, $second, $month, $day,$year); //3rd november 2001
//$start_time = mktime(1, 13, 0,1 ,25, 2004); //2nd november 2001
//every minute
$time_interval=5;
PHP Code:
include("th.php");
$databasehosts = "localhost"; // host with mySQL on it
$databasename = "mugran"; // mySQL database name
$tablename = "music"; // mySQL table name
$dbusers = "mugransql";
$dbpasss = "mughmv4";
$dbs = mysql_connect($databasehosts,$dbusers,$dbpasss)
or die("Unable to connect to mySQL server - please check configuration");
mysql_select_db($databasename,$dbs);
$now = date("j-m-y");
$nw = date("g:i:s");
function str(&$i, &$index) {
if (!($i))
{
$index=0;
$new = mysql_query("SELECT * FROM music ,$dbs);
trigger_error('Query error ' . mysql_error() . ' SQL: ' . $new);
echo "if I=0 i = $i before access resulting IMAGE RESULT passing 0 index=$index !!!!!\n";
cho "newresult = $new\n";
$img = mysql_result($new,0,"image");
}
else
{
echo "ELSE i > 0i = $i before access resulting IMAGE\n";
$img = mysql_result($result,$i,"image");
}
echo " For $i $img \n";
$imageln = "http://www.mugran.com/training/img/$img";
//printf("<img src=\"$imageln\"><br>\n ");
}
$index = floor((time() - $start_time) / $time_interval);
$query = "SELECT * FROM $tablename ORDER BY id DESC LIMIT 1";
$res = mysql_query ($query) or die ("Query failed");
while ( $row = mysql_fetch_object($res) )
{
echo "The id is: ".$row->id."<br>\n";
$last = "$row->id";
}
if (!($index < 0 ))
{
if (($index > $last)) {
echo "ENDED FOR ROW = $last resetting at to id = 0\n";
$a=0;
str($a, $index);
}
else { str($index); }
}
else {
echo " BEFORE TIME SCRIPT START INITIALIZE IMAGES + LINKS\n";
$b=0;
str($b);
}
I get the following error message:
before access resulting IMAGE RESULT passing 0 result = Resource id #6
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 6 in /home/sites/site23/web/training/time/t1.php on line 37
Comment