trinistorm Posted December 25, 2009 Share Posted December 25, 2009 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! Link to comment Share on other sites More sharing options...
Synook Posted December 25, 2009 Share Posted December 25, 2009 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 More sharing options...
trinistorm Posted December 25, 2009 Author Share Posted December 25, 2009 Great it works.Thanks a lot Synook! Link to comment Share on other sites More sharing options...
jlhaslip Posted December 25, 2009 Share Posted December 25, 2009 try this: str_replace("%2F", "/", urlencode($url)); Link to comment Share on other sites More sharing options...
trinistorm Posted December 25, 2009 Author Share Posted December 25, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.