troubleshooting Question

PHP/MySQL 2nd query problem

Avatar of dresdena1
dresdena1 asked on
PHPMySQL Server
13 Comments2 Solutions423 ViewsLast Modified:
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/maketable/make_galleries.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.""."\">Test $H1</a>"." "  ;

            $out = fopen( "/usr/home/abc123/public_html/maketable/$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_description\"> " ) ;

              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 ) ;
      }

?>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros