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




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 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

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: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




[PHP] Appending url to file name...

2002-04-08 Thread Jas

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.
My code is as follows:
Page 1- index.php (queries database to display current db contents and also
queries directory and places results into an array that is displayed in a
select box)


";
 while ($file_name = readdir($dir)) {
  if (($file_name != ".") && ($file_name !="..")) {
  $file_list .= "$file_name";
  }
 }
 $file_list .= "";
 closedir($dir);
$table = "table_nae";
$dbh = mysql_connect('localhost','user_name','password') or die('Could not
connect to database, please try again later');
mysql_select_db('db_name') or die('Could not select database, please try
again later');
$record = @mysql_query("SELECT wel_area, ad01_t, ad01, ad02_t, ad02, ad03_t,
ad03, ad04_t, ad04, ad05_t, ad05, ad06_t, ad06 FROM $table",$dbh);
while ($row = mysql_fetch_array($record)) {
 list($wel_area, $ad01_t, $ad01, $ad02_t, $ad02, $ad03_t, $ad03, $ad04_t,
$ad04, $ad05_t, $ad05, $ad06_t, $ad06) = $row;
}?>

This echoes the resulting directory into my select box...


And this will echo the existing db entry...


Ok so far so good, now the items that are selected from the drop box need to
somehow (this is where I am stuck append the file path, i.e. the complete
url to the db entry and I am not quite sure how to accomplish this, if
anyone has a tutorial or even an example to show me I can figure it out from
there... this is the piece of code I am using on the "index_done.php3" file.


Any help would be great...
Jas





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