Hi there. Here's the scenario:
I have a couple folders on images stored in Amazon AWS cloud storage. I can access each image with a URL. I want to store the URL for each image in a mySQL DB, which is also located in the cloud, at Amazon.
I have found many PHP scripts for inserting the image URL into the DB, but I am creating the DB using MySQL Query Browser, not PHP. So my question is, what is the MySQL correct syntax to insert a URL into a table. I have been using this:
INSERT INTO image_test
VALUES (NULL, "https://s3.amazonaws.com/myimagefolder/image1.JPG");
The datatype for the URL is VARCHAR.
This seems to be working, but I am having trouble retrieving the image. To retrieve I am using a PHP script as follows:
mysql_connect($dbhost, $dbuser, $dbpass) or die("Can not connect to database: ".mysql_error());
mysql_select_db($dbname) or die("Can not select the database: ".mysql_error());
$query = mysql_query("SELECT * FROM image_test WHERE pid=2");
$row = mysql_fetch_array($query);
$content = $row['image_url'];
I have also tried varies other ways of opening the URL, such as:
echo "<img src='$row['image_url']';>"
<img src="<?php echo $row['image_url'] ?>">
None of which have worked. I am not sure if the issue is with uploading the URL, or retrieving it, so I want to post on here, to ensure I am starting out correctly with the URL insert.
Any hints, tips, or a good tutorial would be appreciated, thanks.
EDIT-- I have been doing some more testing, and found the the issue seems to be, the insert method I am using is not putting the full URL in the DB. I inserted a few rows, then queried what was there, and here are the results:
As you can see, the image names are missing. What could be causing this?
Edited 1 time(s). Last edit at 07/25/2011 10:16AM by Simon Rodgers.