php-windows Digest 17 Jan 2011 18:13:13 -0000 Issue 3906

Topics (messages 30468 through 30470):

Re: [Bulk] Fwd: Re: [PHP-WIN] Error: Not a proper resource --- with code this 
time!
        30468 by: Bill Mudry
        30469 by: Lars Mueller

Re: Error: Not a proper resource --- with code this time!
        30470 by: Niel Archer

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---


At 08:06 PM 1/16/2011, Bill Mudry wrote:

X-Apparently-To: billmu...@rogers.com via 206.190.37.191; Sun, 16 Jan 2011 12:58:19 -0800
X-YMailISG: 6IyfGVwcZAolrREihPxcaZJx7VkI8KmrvpK2cIzILvqDHzS9
 bpXFKEo3ttD4ShKY2q6wz7M0VD_W49UPhTUK9PtkwCIAoL8yYDmvz3WvA_QY
 uOtcL.0r0GVnnPY._MM44NpRinL61N39mZSyA0vyshF8Ml3jRYONWZ2x1_Qv
 e_y5M9wTeC8HMX0_JN0OU1MWHlOVEe7HfGH3jX283jLJjIaJpnF4K8w_6pEv
 5VPFpnUApcMoJlVkd92cdxkleEaNM.iFDRcc_Xn._Lc0i5god7QPHyu6uaZv
 PPrUFvh9i5FrxBJa8lrcyulkQU8XQwGsVfwwhdhJkzoqooItclhZGWQQSGqL
 9jyKDoN17p00geBpvPunM_NQlChoVEUg0CRIKRPaLPQr8fN3jQriXY33fkub
 KXJmPnWX6kaQS.22Bmopjz6XbsUZkfKUjXv4iqe3a0q8UnVlGo.ugacfUMKL
 TtzBHultKdb5aqhYMjE4JLncD708D41jhKkuixqgxqDyXaUFyJzQlNR4UUvt
 0ITdpjB2Ll1iKtsj1JT6lEv8ExFp._pCu8ayDSOlh8UsUElM6nK9xE.QDalN
 CS6IRWAsQW2JyARyw1UuvhXMFU_FAdd6.NWLUnIxsmF7POVqsw--
X-Originating-IP: [76.75.200.58]
Authentication-Results: mta1001.rog.mail.sp1.yahoo.com from=yahoo.de; domainkeys=neutral (no sig); from=yahoo.de; dkim=permerror (bad sig)
X-Host-Fingerprint: 76.75.200.58 pb1.pair.com
Mailing-List: contact php-windows-h...@lists.php.net; run by ezmlm
list-help: < mailto:php-windows-h...@lists.php.net>
list-unsubscribe: < mailto:php-windows-unsubscr...@lists.php.net>
list-post: < mailto:php-wind...@lists.php.net>
List-Id: php-windows.lists.php.net
Delivered-To: mailing list php-wind...@lists.php.net
Authentication-Results: pb1.pair.com smtp.mail=cobi...@yahoo.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=cobi...@yahoo.de; sender-id=unknown
X-PHP-List-Original-Sender: cobi...@yahoo.de
X-Host-Fingerprint: 98.139.212.172 nm13.bullet.mail.bf1.yahoo.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1295211472; bh=IdykF5YjKiZoaZrGPumJHpZInxsOj9nKmMzsStMHx24=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=N4QXKF5e6uhF/LfR6x8MmEGtcOvSyQf1DYSbf+qIBiyZ+JcyHvobKSh8LjR5WPwwHuXUCgLelDgeNWV86aaoUDC6FzZkS+Co+pZi7NnP+oqyUx3TcW1Q0J29IVw3N5xNjkDxvwDAQSRKYDi2bbGNzH5r0IyFKH5Bkvu8os4KlNA=
X-Yahoo-Newman-Id: 619138.57359...@smtp111.mail.bf1.yahoo.com
X-Yahoo-SMTP: wQb7PoiswBDDIaOUwhs3y1Z7sRE-
X-YMail-OSG: _UA5GdwVM1mpaMDCk1V7eKI9qRSVFoUCGQ3PYinwqJpthdU
 Yp7FqAy0KTHGLAFFLh1YHuUJinBVeLwGhU_xJdgH9uN3ifKJwZxXHyt8in8j
 VGyZ3Z2V66NmS.kpx_6r7nYe3.CNn8EI4gcIjR6gx_i2VXqZmr3URoQ.fTmM
 6jv.5.d7_ntKTC46H9hgCtn6VvcEVJyW6B37gDNf1kYxmsTGUR6_SbEZ_Wfs
 -
Date: Sun, 16 Jan 2011 21:57:47 +0100
From: Lars Mueller <cobi...@yahoo.de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7
To: php-wind...@lists.php.net
Subject: Re: [PHP-WIN] Error: Not a proper resource --- with code this time!

Am 15.01.2011 17:35, schrieb Bill Mudry:

Lars, thank you for your effort and willingness to help. Unfortunately,
we have a way to go yet for success:



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

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

When I substituted this suggestion I got the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''uvphotos' WHERE `species_name` = ''' at line 1


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

When I tried this, I found more information on mysql_real_escape() at:
        http://php.net/manual/en/function.mysql-real-escape-string.php
With this proof that it is a valid function, it is hard to understand the
error I got when I used your second suggestion. I was surprising:

Fatal error: Call to undefined function mysql_real_escape() in /home/content/b/i/l/billmudry/html/taxa/show_uv_photos.php on line 69

Sooo ..... I will wish you and anyone else the best but we are not at a working solution yet.

I was thinking of listing only the section of interest but just to be on the safe
if not complete side, I will list below the full page code as it stands.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

[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'";


        //WHERE `species_name` = '".mysql_real_escape($speciesname)."'";
        //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]
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



--- End Message ---
--- Begin Message ---
Am 17.01.2011 03:24, schrieb Bill Mudry:

When I tried this, I found more information on mysql_real_escape() at:
>
http://php.net/manual/en/function.mysql-real-escape-string.php
>
With this proof that it is a valid function, it is hard to understand the
error I got when I used your second suggestion. I was surprising:

Fatal error: Call to undefined function mysql_real_escape() in


Sorry, my mistake.

Of course, the function is called mysql_real_escape_string(), not mysql_real_escape(). You'll have to replace that in your source code.

And please note that it's not single-quotes with the table- and column-names, but the grave accent.

What I also noticed: You're using
> //ECHO "Session variable for species name is - {$_SESSION['species_name']}"; //Debug statement

but also

> $speciesname = $_SESSION["speciesname"];

Which one is the correct spelling of the array index?

--- End Message ---
--- Begin Message ---
> 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



--- End Message ---

Reply via email to