Jump to content

Mysql-storing File Locations


trinistorm
 Share

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!

Edited by sansana
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...