Re: [PHP-DB] Storing Image Location in MySQL
Phpster wrote: On Feb 22, 2009, at 5:17, Joao Gomes Madeira wrote: Hey Sashi You want something similar to this: (you must have GD installed on Apache) you can have this working by doing something like this in HTML: and having as picture.php: Error getting image...'; } else { header('Content-Type: image/jpeg'); imagejpeg($img); imagedestroy($img); } ... Cheers JP -Original Message- From: Sashikanth Gurram To: php-db@lists.php.net Subject: [PHP-DB] Storing Image Location in MySQL Date: Sun, 22 Feb 2009 03:43:06 -0500 Dear All, I am trying to store the location of a image into MySQL database, so that I can call it back from PHP to display it in a browser. For this purpose, I have created a table with two columns (BuildingCode, Location), where building is the primary key and location is the location where my picture is stored on my PC. My image is stored at /C:\Users\Sashikanth\Desktop\burruss.jpg/ on my PC. The following table is an output from MySQL. +--+-+ | BuildingCode | Location| +--+-+ | 176 | c:/users/sashikanth/desktop/burruss.jpg | +--+-+ Considering my original Image Location on my PC, will the above table be of any help if I try to retrieve the image using PHP? Is there any mistake in what I have done till now? I know that this may be a very basic question and i have searched through the internet quite extensively but could not find a solid answer. Would appreciate it greatly if anyone can help. Thanks, Sashi -- ~ ~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Note that the image needs to be accessible by apache. You may want to store those images in a folder in or just above the web root and perhaps create an image upload routine Bastien Hi Bastien, I did not quite get what you have said. Does it really matter where we store the image? I mean, we can always retrieve the location and display it as long as we feed the db with the correct path. And what is meant by a image upload routine? -Sashi -- ~ ~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Storing Image Location in MySQL
Hi JP, Can you please let me know what is a GD? I have not installed Apache separately. I am using the WAMP server currently. Do I have to install any additional stuff before I can retrieve the image location from the db and display it in my browser? -Sashi Joao Gomes Madeira wrote: Hey Sashi You want something similar to this: (you must have GD installed on Apache) you can have this working by doing something like this in HTML: and having as picture.php: Error getting image...'; } else { header('Content-Type: image/jpeg'); imagejpeg($img); imagedestroy($img); } ... Cheers JP -Original Message- From: Sashikanth Gurram To: php-db@lists.php.net Subject: [PHP-DB] Storing Image Location in MySQL Date: Sun, 22 Feb 2009 03:43:06 -0500 Dear All, I am trying to store the location of a image into MySQL database, so that I can call it back from PHP to display it in a browser. For this purpose, I have created a table with two columns (BuildingCode, Location), where building is the primary key and location is the location where my picture is stored on my PC. My image is stored at /C:\Users\Sashikanth\Desktop\burruss.jpg/ on my PC. The following table is an output from MySQL. +--+-+ | BuildingCode | Location| +--+-+ | 176 | c:/users/sashikanth/desktop/burruss.jpg | +--+-+ Considering my original Image Location on my PC, will the above table be of any help if I try to retrieve the image using PHP? Is there any mistake in what I have done till now? I know that this may be a very basic question and i have searched through the internet quite extensively but could not find a solid answer. Would appreciate it greatly if anyone can help. Thanks, Sashi -- ~ ~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Storing Image Location in MySQL
Thanks fir the suggestion Chris -Sashi Chris wrote: Sashikanth Gurram wrote: Dear All, I am trying to store the location of a image into MySQL database, so that I can call it back from PHP to display it in a browser. For this purpose, I have created a table with two columns (BuildingCode, Location), where building is the primary key and location is the location where my picture is stored on my PC. My image is stored at /C:\Users\Sashikanth\Desktop\burruss.jpg/ on my PC. The following table is an output from MySQL. +--+-+ | BuildingCode | Location| +--+-+ | 176 | c:/users/sashikanth/desktop/burruss.jpg | +--+-+ Considering my original Image Location on my PC, will the above table be of any help if I try to retrieve the image using PHP? Is there any mistake in what I have done till now? I know that this may be a very basic question and i have searched through the internet quite extensively but could not find a solid answer. Would appreciate it greatly if anyone can help. Don't store the full path to the image, just store the relative path. If you move your app to a new folder, then you have to go through and update all database records to point to the new path. If you store the relative path, you can set a config variable (or work it out yourself), and add the relative path to the end. So in your config: $cfg['folder_name'] = 'c:/apps/my_app_name/'; in the db location will be 'images/image.jpg'; Put the two together to get the full path: $image_path = $cfg['folder_name'] . $db['location']; -- ~ ~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Issue 45979: PHP code attached
This is the page called ~~~ Then you would need to redirect the user to the form page to get the data from the user. Or create an application account that the rest of the application would use. Frankly there is no way that I would ever ask the user for the credentials, if they need different user accounts, I would create each one on the server and allow the application to control what accounts are used. I was suggesting that was the cause of the problem (no post variables). I'd ask a user for the details during an install phase of an app, but that's it. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Issue 45979: PHP code attached
On Sun, Feb 22, 2009 at 4:43 PM, Chris wrote: > > This is the page called >> ~~~ >> >> > #phpinfo(); # phpinfo displays the correct info. >> #exit; >> >> $sqldb= $_POST["sqldb"]; >> $sqluser = $_POST["sqluser"]; >> $sqlpass = $_POST["sqlpass"]; >> $sqlhost = $_POST["sqlhost"]; >> >> $link = mysql_connect($sqlhost, $sqluser, $sqlpass); >> > > What happens if I somehow hit the page directly instead of through the > previous page's form? There are no $_POST variables. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Then you would need to redirect the user to the form page to get the data from the user. Or create an application account that the rest of the application would use. Frankly there is no way that I would ever ask the user for the credentials, if they need different user accounts, I would create each one on the server and allow the application to control what accounts are used. -- Bastien Cat, the other other white meat
Re: [PHP-DB] Storing Image Location in MySQL
Sashikanth Gurram wrote: Dear All, I am trying to store the location of a image into MySQL database, so that I can call it back from PHP to display it in a browser. For this purpose, I have created a table with two columns (BuildingCode, Location), where building is the primary key and location is the location where my picture is stored on my PC. My image is stored at /C:\Users\Sashikanth\Desktop\burruss.jpg/ on my PC. The following table is an output from MySQL. +--+-+ | BuildingCode | Location| +--+-+ | 176 | c:/users/sashikanth/desktop/burruss.jpg | +--+-+ Considering my original Image Location on my PC, will the above table be of any help if I try to retrieve the image using PHP? Is there any mistake in what I have done till now? I know that this may be a very basic question and i have searched through the internet quite extensively but could not find a solid answer. Would appreciate it greatly if anyone can help. Don't store the full path to the image, just store the relative path. If you move your app to a new folder, then you have to go through and update all database records to point to the new path. If you store the relative path, you can set a config variable (or work it out yourself), and add the relative path to the end. So in your config: $cfg['folder_name'] = 'c:/apps/my_app_name/'; in the db location will be 'images/image.jpg'; Put the two together to get the full path: $image_path = $cfg['folder_name'] . $db['location']; -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Issue 45979: PHP code attached
This is the page called ~~~ What happens if I somehow hit the page directly instead of through the previous page's form? There are no $_POST variables. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP5: Initial connection to the MySQL server is carried out using the apache webserver userid
Paul Will wrote: Hi, When I attempt to connect to a MySQL database I have noticed that the initial connection is made using the "wwwrun" userid (this is the userid that my Apache2 webserver is running under.) This is the output I see from the Firefox "View Frame Info Function" Notice: Undefined index: db in /srv/www/htdocs/LMsummary.php5 on line 23 Notice: Undefined index: user in /srv/www/htdocs/LMsummary.php5 on line 24 Notice: Undefined index: pass in /srv/www/htdocs/LMsummary.php5 on line 25 Notice: Undefined index: host in /srv/www/htdocs/LMsummary.php5 on line 26 Fix these errors and it'll probably connect as the right user. You're trying to access part of an array that doesn't exist, like this: $db = array(); mysql_connect($db['host'], $db['user'], $db['pass']); -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Storing Image Location in MySQL
On Feb 22, 2009, at 5:17, Joao Gomes Madeira wrote: Hey Sashi You want something similar to this: (you must have GD installed on Apache) you can have this working by doing something like this in HTML: and having as picture.php: Error getting image...'; } else { header('Content-Type: image/jpeg'); imagejpeg($img); imagedestroy($img); } ... Cheers JP -Original Message- From: Sashikanth Gurram To: php-db@lists.php.net Subject: [PHP-DB] Storing Image Location in MySQL Date: Sun, 22 Feb 2009 03:43:06 -0500 Dear All, I am trying to store the location of a image into MySQL database, so that I can call it back from PHP to display it in a browser. For this purpose, I have created a table with two columns (BuildingCode, Location), where building is the primary key and location is the location where my picture is stored on my PC. My image is stored at /C:\Users\Sashikanth\Desktop\burruss.jpg/ on my PC. The following table is an output from MySQL. +--+-+ | BuildingCode | Location| +--+-+ | 176 | c:/users/sashikanth/desktop/burruss.jpg | +--+-+ Considering my original Image Location on my PC, will the above table be of any help if I try to retrieve the image using PHP? Is there any mistake in what I have done till now? I know that this may be a very basic question and i have searched through the internet quite extensively but could not find a solid answer. Would appreciate it greatly if anyone can help. Thanks, Sashi -- ~ ~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Note that the image needs to be accessible by apache. You may want to store those images in a folder in or just above the web root and perhaps create an image upload routine Bastien -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Storing Image Location in MySQL
Hey Sashi You want something similar to this: (you must have GD installed on Apache) you can have this working by doing something like this in HTML: and having as picture.php: Error getting image...'; } else { header('Content-Type: image/jpeg'); imagejpeg($img); imagedestroy($img); } ... Cheers JP -Original Message- From: Sashikanth Gurram To: php-db@lists.php.net Subject: [PHP-DB] Storing Image Location in MySQL Date: Sun, 22 Feb 2009 03:43:06 -0500 Dear All, I am trying to store the location of a image into MySQL database, so that I can call it back from PHP to display it in a browser. For this purpose, I have created a table with two columns (BuildingCode, Location), where building is the primary key and location is the location where my picture is stored on my PC. My image is stored at /C:\Users\Sashikanth\Desktop\burruss.jpg/ on my PC. The following table is an output from MySQL. +--+-+ | BuildingCode | Location| +--+-+ | 176 | c:/users/sashikanth/desktop/burruss.jpg | +--+-+ Considering my original Image Location on my PC, will the above table be of any help if I try to retrieve the image using PHP? Is there any mistake in what I have done till now? I know that this may be a very basic question and i have searched through the internet quite extensively but could not find a solid answer. Would appreciate it greatly if anyone can help. Thanks, Sashi -- ~ ~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Storing Image Location in MySQL
Dear All, I am trying to store the location of a image into MySQL database, so that I can call it back from PHP to display it in a browser. For this purpose, I have created a table with two columns (BuildingCode, Location), where building is the primary key and location is the location where my picture is stored on my PC. My image is stored at /C:\Users\Sashikanth\Desktop\burruss.jpg/ on my PC. The following table is an output from MySQL. +--+-+ | BuildingCode | Location| +--+-+ | 176 | c:/users/sashikanth/desktop/burruss.jpg | +--+-+ Considering my original Image Location on my PC, will the above table be of any help if I try to retrieve the image using PHP? Is there any mistake in what I have done till now? I know that this may be a very basic question and i have searched through the internet quite extensively but could not find a solid answer. Would appreciate it greatly if anyone can help. Thanks, Sashi -- ~ ~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php