php-windows Digest 2 Nov 2004 05:45:58 -0000 Issue 2450
Topics (messages 24861 through 24865):
Re: Displaying An Image / Non-Web accessible Dir
24861 by: Warren Vail
24865 by: Armando
Re: Problems with mysql_num-rows()
24862 by: Svensson, B.A.T. (HKG)
Re: 3 is not a valid MySQL result resource
24863 by: Henrik Hornemann
Help needed PHP/MySQL
24864 by: Garth Hapgood - Strickland
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
I would thing you could do something similar using the GD "image" functions,
http://www.php.net/manual/en/ref.image.php
in your html page code <img src="path/to/imagemodule.php"> and this module
would
basically;
1. determine the type of image (jpec, gif, etc) (note you can pass ?parms
in get format to your imagemodule
in the src reference above)
2. output the correct mime headers for that type of image
http://www.php.net/manual/en/function.header.php
header('Content-type: image/jpeg');
header('Content-Length: $len');
3. $img = imagecreatefromxxx("/full/path/to/image/file.xxx") where xxx is
the type of image
----- here you have an opportunity to do all kinds of things like resize
the image to a thumbnail, add text
overlays, etc.
4. imagexxx($img); where xxx is the type of image actually will output the
image behind the headers
....that's all there is
If there are better PHP options, hopefully someone will provide them here.
Good Luck,
Warren Vail
-----Original Message-----
From: Armando [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 31, 2004 10:29 PM
To: PHP Windows List
Subject: [PHP-WIN] Displaying An Image / Non-Web accessible Dir
Greetings!
I'm porting all my old ASP websites to PHP and have run into a small
problem. One of my pages is a gallery in which images can (should) only
be viewed by authenticated users in my MySQL database. The images are
stored in a non-web accessible directory. For example.. say my root
website is in 'C:\www\webroot' and the gallery images are in
'C:\www\gallery'.
On my ASP page what I did was have the <img> tag call to an ASP page
which would open the file from the actual location on the disk, then
stream it to the page. ASP's filesystemobject and adodb stream
references open the file and do a binary-write to the page to display
the image. Since the page is ASCII and the image data is binary, you
cannot mix the two on the same page, hence the reason for the <img> tag
calling to a separate ASP page.
Now my problem is I'd like to do the same thing in PHP but am not
exactly sure how to go about doing this. I've tried a number of the
filesystem references, but have had no luck so far. I'm assuming I have
to do a similar thing by having my <img> tag call to a PHP page to get
the image, which is easy enough, but I can't figure out how to display
the image from that page. I'm just not familiar enough with PHP yet to
do this.
Any help would be greatly appreciated! Cheers.
Armando
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Thanks for the information Warren.
I am actually already passing parameters to the page for the file types
(at least I was in ASP and will now do so in PHP as well) and I'm pretty
sure I can figure out how to get the image created with your
recommendations below now that I enabled the GD libs and verified
they're working with a var_dump of gd_info().
What my problem really is right now is I can't seem to use the
filesystem objects to open an image file from somewhere on my drive.
What I'd like to do just to test is at least display the filesize of an
image (for the content-length header and to display the filesize of an
image on my page) and I can't seem to get it to work. I've tried using
fopen, fread, readfile, and others but honestly I'm still very new and
not sure how to go about doing this so not even sure which object I
need.
Can you or someone suggest how I can access an image file on my drive
which is not part of the http-accessible directories (say in
C:\images\somepic.jpg) and display the filetype? I think once I can at
least get that to work, the rest should be fairly simple.
FYI - I'm running PHP 5.0.2 , http server is Apache 2.0.51, and o/s is
Win2K Server. Thanks again, and cheers.
Armando
-----Original Message-----
From: Warren Vail [mailto:[EMAIL PROTECTED]
Sent: November 1, 2004 1:37 AM
To: Armando; PHP Windows List
Subject: RE: [PHP-WIN] Displaying An Image / Non-Web accessible Dir
I would thing you could do something similar using the GD "image"
functions,
http://www.php.net/manual/en/ref.image.php
in your html page code <img src="path/to/imagemodule.php"> and this
module would
basically;
1. determine the type of image (jpec, gif, etc) (note you can
pass ?parms in get format to your imagemodule
in the src reference above)
2. output the correct mime headers for that type of image
http://www.php.net/manual/en/function.header.php
header('Content-type: image/jpeg');
header('Content-Length: $len');
3. $img = imagecreatefromxxx("/full/path/to/image/file.xxx")
where xxx is the type of image
----- here you have an opportunity to do all kinds of things
like resize the image to a thumbnail, add text
overlays, etc.
4. imagexxx($img); where xxx is the type of image actually will
output the image behind the headers
....that's all there is
If there are better PHP options, hopefully someone will provide them
here.
Good Luck,
Warren Vail
-----Original Message-----
From: Armando [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 31, 2004 10:29 PM
To: PHP Windows List
Subject: [PHP-WIN] Displaying An Image / Non-Web accessible Dir
Greetings!
I'm porting all my old ASP websites to PHP and have run into a small
problem. One of my pages is a gallery in which images can (should) only
be viewed by authenticated users in my MySQL database. The images are
stored in a non-web accessible directory. For example.. say my root
website is in 'C:\www\webroot' and the gallery images are in
'C:\www\gallery'.
On my ASP page what I did was have the <img> tag call to an ASP page
which would open the file from the actual location on the disk, then
stream it to the page. ASP's filesystemobject and adodb stream
references open the file and do a binary-write to the page to display
the image. Since the page is ASCII and the image data is binary, you
cannot mix the two on the same page, hence the reason for the <img> tag
calling to a separate ASP page.
Now my problem is I'd like to do the same thing in PHP but am not
exactly sure how to go about doing this. I've tried a number of the
filesystem references, but have had no luck so far. I'm assuming I have
to do a similar thing by having my <img> tag call to a PHP page to get
the image, which is easy enough, but I can't figure out how to display
the image from that page. I'm just not familiar enough with PHP yet to
do this.
Any help would be greatly appreciated! Cheers.
Armando
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Do:
$query = "SELECT * from user where name='$userid' and
pass=password('$password')";
echo $query. ".r\n";
See what the string looks like, and if you can replicate the problem by
trying to execute that string in the mysql.exe command line tool.
You ererror suggest that you have some kind of syntax error in your query.
You can also test for an error directly after you have executed the query:
if ($result) {
$result = mysql_query($query, $link);
$num_rows = mysql_num_rows($result);
} else {
// call mysql's error function
}
-----Original Message-----
From: Arne Essa Madsen
To: [EMAIL PROTECTED]
Sent: 31-10-2004 19:34
Subject: [PHP-WIN] Problems with mysql_num-rows()
I have the following problem:
This one does not work:
$query = "SELECT * from user where name='$userid' and
pass=password('$password')";
$result = mysql_query($query, $link);
$num_rows = mysql_num_rows($result);
I get this error message:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in c:\wamp\www\fs1812_new\authmain.php on line 18
This one works OK:
$query = "SELECT * FROM user";
$result = mysql_query($query, $link);
$num_rows = mysql_num_rows($result);
What is wrong and how can I use mysql_num_rows when the query include
"WHERE"
A fast response will be very much appreciated.
Arne Essa Madsen;
[EMAIL PROTECTED]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Well, you freed $Recordset1 just before yoy entered the loop, so
naturally you cant keep fetching from it.
Regards Henrik Hornemann
-----Oprindelig meddelelse-----
Fra: Ross Hulford [mailto:[EMAIL PROTECTED]
Sendt: 31. oktober 2004 21:29
Til: [EMAIL PROTECTED]
Emne: [PHP-WIN] mysql_fetch_assoc(): 3 is not a valid MySQL result
resource
This is my code...........................
<?php require_once('Connections/ross.php'); ?> <?php
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1']; }
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_ross, $ross);
$query_Recordset1 = "SELECT portfolio.location_name FROM portfolio";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1,
$startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $ross) or
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1); }
$totalPages_Recordset1 =
ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
mysql_free_result($Recordset1);
?>
<?php echo $totalRows_Recordset1 ?>
<?php do { ?>
<p><?php echo $row_Recordset1['location_name']; ?></p> <?php } while
($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
It displays one result then thows up the following error
Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in
c:\inetpub\wwwroot\testy\Untitled-1.php on line 29
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I have written a registration page in php and have a number of edit boxes
and drop-down lists. The lists are pulling data out of their respective
tables, whereas the edit boxes are just for saving data.
Now my main table where all my data is being saved is called Business. Onto
this I have a table called BusinessCommunication which has the fields
(BusinessCommunicationID, BusinessID, CommunicationTypeID, Destination).
BusinessCommunicationID = Primary Key
BusinessID = Foreign key from Business Table
CommunicationTypeID = Foreign key from CommunicationType table (lists all
communication types)
Destination = field where data is stored (tel number, email address or fax
number etc)
Now the problem is that I want the person registering to be able to select
the Communication Type/s he wants to add and then be able to enter the
relevant information for each selected CommType. There must also be ability
to add 2 of the same CommType.
How can I achieve this as simply and affective as possible on my
registration page.
If you have any solutions are need more information. Please let me know
Many thanx
Garth
--- End Message ---