Re: [PHP] Appending url to file name...

2002-04-08 Thread Erik Price


On Monday, April 8, 2002, at 11:09  AM, Jas wrote:

 Ok this is an unusual problem, at least to a newbie like myself... I am
 trying to develop a user form to select an image from a directory by 
 use of
 a select box that once the item is selected it will put that selection 
 into
 a db field and this part I have working fine, however now I will need 
 to be
 able to do something which I am not entirely clear on where to start...
 1- I need to have the selection append the file path to the selected 
 file...
 i.e. http://localhost/images/file_name.jpg, so far it only puts
 file_name.jpg into the database table.

If you already know that the file will always be in the same directory, 
you could just prepend the string http://localhost/images/; to the 
query result in your query --

SELECT CONCAT('http://localhost/images/', tablename.image_name) AS 
image_name FROM tablename

Or, if each file may have a different path, check out the dirname() 
function -- http://www.php.net/manual/en/function.dirname.php

I think that you will have to add http://virtualhost; in any case, as 
this is a component of a URI and not a part of the file's path (and will 
not be automatically generated by dirname() or any other function that I 
know of).


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] Appending url to file name...

2002-04-08 Thread Jas

So putting it into an UPDATE statement it would be something like this
right?
UPDATE CONCAT $table_name SET ('http://localhost/images') ad01=\$ad01\;




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




Re: [PHP] Appending url to file name...

2002-04-08 Thread Erik Price


On Monday, April 8, 2002, at 11:35  AM, Jas wrote:

 So putting it into an UPDATE statement it would be something like this
 right?
 UPDATE CONCAT $table_name SET ('http://localhost/images') 
 ad01=\$ad01\;

No, like this:

The table is named test_table
The column you want to add this to is named test_column

You are taking the data that test_column contains, and prepending 
http://localhost/images; to the beginning of that data:

UPDATE test_table SET test_column = CONCAT('http://localhost/images', 
test_table.test_column)

Warning: This command will change every single row in your table so that 
'http://localhost/images' will be prepended before whatever data is 
already in that row.  You probably want to make ABSOLUTELY SURE that 
this is what you want (are you sure you don't want a trailing slash in 
that CONCAT function?).  If you want to just test this out, or don't 
want to apply this change to EVERY row, you can add a WHERE clause to 
choose certain rows to update.

Keep in mind that test_column must be able to accommodate the new string 
(so you might need to make it a bigger VARCHAR or something).

Good luck,

Erik




Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] Appending url to file name...

2002-04-08 Thread Jas

Actually, I tried it a different way and I got the results I needed... this
is what I did,
$file_var = http://www.bignickel.net/full_ad/;;
$db_name = db_name;
$table_name = table_name;
$connection = mysql_connect(localhost, user_name, password) or die
(Could not connect to database.  Please try again later.);
$db = mysql_select_db($db_name,$connection) or die (Could not select
database table. Please try again later.);
$sql = UPDATE $table_name SET ad01_t=\$file_var$files\; //this gave me
the results, as you can see I just created a new variable with the path in
it
print $sql;
$result = mysql_query($sql, $connection) or die (Could not execute query.
Please try again later.);
?



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




Re: [PHP] Appending url to file name...

2002-04-08 Thread Miguel Cruz

On Mon, 8 Apr 2002, Jas wrote:
 $sql = UPDATE $table_name SET ad01_t=\$file_var$files\;

Is this really what you wanted? It would set ad01_t to the same thing for 
every single row in your table.

If that is what you wanted, then I think your database design is a little 
weird.

miguel


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