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

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

am 15.01.2011 17:35:04 von Bill Mudry

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.

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]
//////////////////////////////////////////////////////////// ////////////////////////////////////////////
// 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
?>

"http://www.w3.org/TR/html4/loose.dtd">


TAXA: Ultraviolet Wood Fluorescence







#
//////////////////////////////////////////////////////////// ////////////////////////
# 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 "

";

Echo "

Ultraviolet Fluorescence Photo of
{$_SESSION["speciesname"]}

";

$speciesname = $_SESSION["speciesname"]; //Successful
transfer of ssssion parameter to a variable.
//Echo "The species name is - $speciesname
"; //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
";

//$number=mysql_num_rows($resultuv); // This and the next
line only to debug a warning
//ECHO "Number of rows is - $number
";

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

";

//$uvfilename = "uva/acacia_anura-mulgaUV01-800.JPG";
$uvpath = "./uv/$uvfilename";

ECHO "
";

ECHO "
";

Echo "
END OF PICTURE AREA

";

Echo "
";



?>

Webmaster: This function is still Under Construction









>


Close
this Window









[/CODE]


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

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

am 16.01.2011 21:57:47 von Lars Mueller

Am 15.01.2011 17:35, schrieb Bill Mudry:

>
> $uvquery = "SELECT `uv_filename` FROM 'uvphotos' WHERE `species_name`=
> $speciesname";
>

That should probably be
.... FROM `uvphotos` WHERE `species_name` = '$speciesname'";

or better:
....WHERE `species_name` = '".mysql_real_escape($speciesname)."'";

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

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

am 17.01.2011 19:12:45 von Niel Archer

> 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
\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]
> > //////////////////////////////////////////////////////////// ////////////////////////////////////////////
> // 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
> ?>
>
> > "http://www.w3.org/TR/html4/loose.dtd">
>
>
> TAXA: Ultraviolet Wood Fluorescence
>
>
>
>
>
>
> >
> #
> //////////////////////////////////////////////////////////// ////////////////////////
> # 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 "

";
>
> Echo "

Ultraviolet Fluorescence Photo of
> {$_SESSION["speciesname"]}

";
>
> $speciesname = $_SESSION["speciesname"]; //Successful
> transfer of ssssion parameter to a variable.
> //Echo "The species name is - $speciesname
"; //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
";
>
> //$number=mysql_num_rows($resultuv); // This and the next
> line only to debug a warning
> //ECHO "Number of rows is - $number
";
>
> 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

";
>
> //$uvfilename = "uva/acacia_anura-mulgaUV01-800.JPG";
> $uvpath = "./uv/$uvfilename";
>
> ECHO "
";
>
> ECHO "
";
>
> Echo "
END OF PICTURE AREA

";
>
> Echo "
";
>
>
>
> ?>
>
>

Webmaster: This function is still Under Construction


>
>
>
>
>
>
>
> > >

>

>

Close
> this Window


>

>

>
>
>
>
>
> [/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

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

am 17.01.2011 19:25:54 von Niel Archer

It occurred to me that you may be over complicating things. Could the
filenames for UV photos not be added as an extra column to the main
table? If that's acceptable you would have the filename available in
the previous page and could pass that through the session variable
instead of the species_name.

If, for whatever reason, the additional table is preferable; you can
still have the filename available by using a JOIN query in the previous
page.

Either way this would save you doing a separate lookup for the filename.

--
Niel Archer



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