Re: Error: Not a proper resource --- with code this time!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Oh foo! I posted before sending the code! This time it will be there. Sorry
> Bill
> --------------------------------------------------------------------------------------------------------
> 
> Thanks to help from the forum, I am a step closer to being able to 
> display a whole bunch of UV fluorescent photos (of wood) but now I
> have come up with an "not a proper resource" error after the SELECT
> statement in trying to go the next step with a mysql_query statement.

Are you saying that the mysql_query() causes the error? if so try
replacing the line with something like:

if (is_resource($connection)) {
  $resultuv = mysql_query($uvquery, $connection);
} else {
  echo "Problem with connection resource<br />\n";
  var_dump($connection);
}

to get an idea of why

Also, what's in the connecttotaxa.php file? Is it just assignments of
$hostname, , $username, $password; or does it also make a connection. If
the former, then the file is confusingly named ;-)

> I am largely sure that it is some error in my SELECT statement and
> most likely an error in punctuation. Whatever it is, I am looking forward
> to getting past this blockade. I have to be getting close to having the
> photos showing. An image does show nicely if I temporarily hard code
> the path and image file name.
> 
> I have tested and found that so far, there are zero records showing.
> There are various commented out lines you will likely wish to just ignore.
> They have been efforts to try to figure out what was wrong.
> 
> The choice of which wood (which botanical name) becomes current is a
> user choice on another page. That is why I turned to using SESSION 
> statements to transfer the name. Only about 10 to 15% of woods I have
> studied glow under UV. Later I will add statements so the UV button
> shows only if there is a photo stored.
> 
> Much thanks. Once I get the full path showing from the database for
> each photo, I should be close to a successful finish.
> 
> Bill Mudry
> Mississauga, Ontario
> 
>          The code follows:
> =======================================================
> [CODE]
> <?php
> ////////////////////////////////////////////////////////////////////////////////////////////////////////
> //  Program: show_uv_photos.php
> //  Description: This program displays Uv fluorescence photos of wood 
> found to glow under an ultraviolet
> //  light. This is around 10% - 15% of all wood species.
> //
> //  It runs as a pop-up window and is activated by a button titled 
> "U.V. Fluorescence" generated by
> //  displayspecies.php. Future code may be added later to display the 
> buttons only if the program can
> //  detect UV photos stored for each species.
> //  PARAMETERS:
> //      {$_SESSION["speciesname"]} - Looks back to find what the 
> current species picked is.
> //              speciesname - The session variable name for the 
> cuurent species.
> //              $speciesname - The standard variable name taken from 
> the session variable.
> //              species_name - the name of the column that stores up 
> to over 15,000 different botanical naes of wood.
> //              uvphotos - the name of the table in the TAXA database 
> that holds the partial path and photo file
> //                      name
> ////////////////////////////////////////////////////////////////////////////////////////////////////////
> session_start();
> 
> //ECHO "Session variable for species name is - 
> {$_SESSION['species_name']}";  //Debug statement
> ?>
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
> "http://www.w3.org/TR/html4/loose.dtd";>
> <HTML>
> <head>
> <title>TAXA: Ultraviolet Wood Fluorescence</title>
> 
> 
> </head>
> 
> <body bgcolor='ivory'>
> 
> <?PHP
> 
> # 
> ////////////////////////////////////////////////////////////////////////////////////
> #                                           CONNECT TO DATABASE
> # 
> ////////////////////////////////////////////////////////////////////////////////////
> 
> 
> 
> include ("connecttotaxa.php");
> $connection = mysql_connect($hostname, $username, $password)
>          or die("Unable to connect to database server");
> 
> $dbname="taxa";
> $db = mysql_select_db($dbname, $connection)
>          or die("Unable to connect to database");
> /*
> --------------------------------------------------------------------------------
>          HOPEFULLY CONNECTED AT THIS POINT
> ---------------------------------------------------------------------------------- 
> 
> */
> 
> ///////////////////////////////////////////////////////////////////////////////////////////////////////
> //      SECTION TO DISPLAY WOOD SCANS
> /////////////////////////////////////////////////////////////////////////////////////////////////////
> 
>          Echo "<div align = 'center'>";
> 
>          Echo "<H2 align=\'center\'>Ultraviolet Fluorescence Photo of
>          {$_SESSION["speciesname"]}</H2>";
> 
>          $speciesname = $_SESSION["speciesname"]; //Successful 
> transfer of ssssion parameter to a variable.
>          //Echo "The species name is - $speciesname<br />"; //Proof 
> that it transferred properly
> 
>          //$uvquery = "SELECT * FROM uvphotos WHERE 'species_name' = 
> $speciesname";
> 
>          $uvquery = "SELECT `uv_filename` FROM 'uvphotos' WHERE 
> `species_name`= $speciesname";
> 
> 
> 
>          //$uvquery = "SELECT * FROM `uvphotos` WHERE `species_name` 
> = '{$_SESSION["speciesname"]}' " or die ('Error: '.mysql_error 
> ());  //No error reported.
> 
>          $resultuv = mysql_query($uvquery) or die(mysql_error());
> 
>          /*
>          if(!$resultuv)
>                  {
>                          die(mysql_error())
>                  };
>          */
>          //Echo "\$resultuv on line 58 is - $resultuv<br />";
> 
>          //$number=mysql_num_rows($resultuv); // This and the next 
> line only to debug a warning
>          //ECHO "Number of rows is - $number<br >";
> 
>          if(mysql_num_rows($uvresults) >0){
>                  $row = mysql_fetch_array($resultuv);
>                  extract($row);
>          }
> 
> 
>          //$uv_filename = row('uv_filename');
> 
>          //ECHO "\$uv_filename on line 62 is - $uv_filename<br /><br />";
> 
>          //$uvfilename = "uva/acacia_anura-mulgaUV01-800.JPG";
>          $uvpath = "./uv/$uvfilename";
> 
>          ECHO "<img src='$uvpath'><br />";
> 
>          ECHO "<HR>";
> 
>    Echo "<br />END OF PICTURE AREA<br /><br />";
> 
> Echo "</div>";
> 
> 
> 
> ?>
> 
> <h4 align="center">Webmaster: This function is still Under Construction</h4>
> 
> 
> 
> <table align='center' cellpadding='10', Cellspacing='20' border =1>
> <tr>
>          <td valign='top'>
>                  <form name='NewWin'>
>                          <p><A href="javascript: self.close ()">Close 
> this Window</A></p>
>                  </form>
>          </td>
> 
> </tr
>  ></table>
> 
> </body>
> </HTML>
> 
> 
> [/CODE] 
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux