Jump to content

Mysql-storing File Locations


trinistorm

Recommended Posts

Hi guys, I am running xampp 1.7.2 with php 5.3.0 and Mysql 5.1 and i am trying to store file paths(uri's) on my database using the following code:

$resource = "R:\\phpset\\xampp\\htdocs\\uploads\\"$insert = "INSERT INTO table(filepath) VALUES('resource')";mysql_query($insert) or die(mysql_error());

It stores to the database but $resource is stored as R:phpsetxampphtdocsuploads (no slashes).If i don't escape the path only the first slash appears ie: R:phpset\xampphtdocsuploadsfilenameI've used text, blob and varchar but to no avail. My collation is utf8 general.Can anyone guide me? Thanks!umnik2.gif

Link to comment
Share on other sites

You need to doubly escape them, as the escape sequences are again interpreted as the query is processed by the DBMS.

$resource = "R:\\\\phpset\\\\xampp\\\\htdocs\\\\uploads\\\\"

Link to comment
Share on other sites

Ok so %2F is ' /' encoded? I used:

$filename = urlencode($filename);

to store to the database and then I just decode when querying These functions seem very useful thanks!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...