I echoed id and returned 1
I echoed description and section and they both didnt return anything. It has something to do with the sql commands but I know there is no error in my typing there so what could be wrong.
I took off the or die function and found more errors. Check it:
Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/projects/photos/photos.php on line 46
Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/projects/photos/photos.php on line 61
<?php
$list = array( '_COOKIE', '_ENV', '_FILES', '_GET','_POST','_SERVER' );
foreach($list as $element) {
if( !empty($$element) && is_array($$element) ) {
extract($$element);
}
}
$user = "oprods";
$pass = "breakin";
$db = "pictures";
$table = $_REQUEST['table'];
$id = $_GET['id'];
$conn = mysql_connect('localhost',$user,$pass) or die(mysql_error());
if(!is_resource($conn)) {
die("Error connecting to mysql.\n");
}
@mysql_select_db($db,$conn);
$sql = "SELECT description,section,id FROM $table WHERE id=$id";
$result = mysql_query($sql,$conn); //or die(mysql_error());
while ($newarray = mysql_fetch_array($result)) {
$description = $newarray['description'];
$section = $newarray['section'];
}
for ($id = 1; $id <= mysql_num_rows($result); $id++ ) {
print '<TR>';
print '<TD width=33%><img src=getdata.php?id='.$id.'&table='.$table.' width=404 height=295></TD>';
print '<TD width=33%>'.$description.'</TD>';
print '<TD width=33%>'.$section.'</TD>';
print '</TR>';
}
echo "The value of ID is ".$id;
echo $description;
echo $section;
?>