EE,
I am trying to write out a series of Gallery image pages. The data is in a MySQL database.
I am using php to write out static html pages.
I need two loops. One for the page itself and then a series of loops to create a table with multiple images.
I am trying to adapt a page that achieved the same result but connected to the database differently (my old ISP - I connect differently to my new ISP). My current problem is writing out data for the 2nd query.
The page connects to the database begins writing out the first page and then stops.
The error message is:
Fatal error: Call to a member function query() on a non-object in /home/abc123/public_html/m
aketable/m
ake_galler
ies.php on line 62
Line 63 is where the 2nd query begins trying to extract data.
I will paste it below (it is greatly abbreviated from the original page, but I believe all necessary information is here - as it is the script will run to line 62).
Any help will be greatly appreciated.
Thank you.
dresdena1
<<
<?php
$connect = mysql_connect("localhost",
"xxx","xxx
");
if (!$connect)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("data");
$sql = 'select * from 402db where category = "Gallery" group by url;';
$result = mysql_query($sql, $connect);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)
) {
$id = $row["id"] ;
$url = $row["url"] ;
$meta_keywords = $row["meta_keywords"] ;
$meta_description = $row["meta_description"] ;
$title = $row["title"] ;
$H1 = $row["H1"] ;
$category = $row["category"] ;
$img = $row["img"] ;
$img_width = $row["img_width"] ;
$img_height = $row["img_height"] ;
$longdesc = $row["longdesc"] ;
echo "\n<BR><a href=\"
http://www.abc123.com/maketable/"."".$url.""."\">Te
st $H1</a>"." " ;
$out = fopen( "/usr/home/abc123/public_h
tml/maketa
ble/$url",
"w" ) ;
fwrite( $out,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
fwrite( $out,"\n\"
http://www.w3.org/TR/html4/strict.dtd\">");
fwrite( $out,"\n<HTML> " ) ;
fwrite( $out,"\n<HEAD> " ) ;
fwrite( $out,"\n<title>" . strtoupper($category) . " </title> " ) ;
fwrite( $out,"\n<META NAME=\"KEYWORDS\" CONTENT=\"$meta_keywords\"
> " ) ;
fwrite( $out,"\n<META NAME=\"DESCRIPTION\" CONTENT=\"$meta_descriptio
n\"> " ) ;
fwrite( $out,"\n</head> " ) ;
fwrite( $out,"\n<body> " ) ;
fwrite( $out,"\n<? include(\"header.html\" ) ?> " ) ;
fwrite( $out,"\n<table width=780><tr><td width=600" ) ;
$query = "select * from 402db where where category = 'Gallery' group by url" ;
// Pass make the request.
$q2->query($query);
$RowCount = $q->num_rows();
$i = 1 ;
// loop trough the items in the categories
while( $q2->next_record() ) {
$id = $row["id"] ;
$url = $row["url"] ;
$img = $row["img"] ;
$img_width = $row["img_width"] ;
$img_height = $row["img_height"] ;
$sm_img = $row["sm_img"] ;
$sm_width = $row["sm_width"] ;
$sm_height = $row["sm_height"] ;
$category = $row["category"] ;
$H1 = $row["H1"] ;
fwrite( $out,"<td><a href=\"$img\" rel=\"Photo[pp]\" title=\"$H1\"><img src=\"$sm_img\" class=\"picthumb\" width=\"150\" height=\"150\" alt=\"$H1\" /></a></td>" ) ;
$i++ ;
}
fwrite( $out,"</tr></table>" ) ;
fwrite( $out,"</body>" ) ;
fwrite( $out,"\n" ) ;
fwrite( $out,"</HTML>" ) ;
fclose( $out ) ;
}
?>
We need some additional information. First, please add error_reporting(E_ALL) to the top of your script so we can be sure that your script is not accidentally relying on any undefined variables.
Next, in consideration of Fatal error: Call to a member function query() on a non-object in /home/abc123/public_html/m
My guess is that there is some "copied code" in here, and that parts of it were procedural and the copied part was object-oriented, but the class definition and object instantiation did not get copied. But that is just a guess and when we begin to flesh out the information we will be able to guide you in the direction of knowing, which is always a better way to work!