phatgreenbuds Posted September 17, 2008 Share Posted September 17, 2008 I have the following code below where I am trying to insert a windows path into a DB field. This is later used to write to an XML file. The problem is when I browse the DB it has the "\" removed. I am not quite sure what I should even search on to resolve this. Anyone know why this happens and how to resolve it? $winpath = "c:\wmpub\WMRoot\MyXfer\Movies"; $count = 1; while ($count <= $times) { $query="INSERT INTO test_tbl (content_path, win_path) VALUES ('$contpath','$winpath')"; $addcon = mysql_query($query); confirm_query($addcon); $count++; } Link to comment https://forums.phpfreaks.com/topic/124581-solved-inserting-a-path-into-mysql/ Share on other sites More sharing options...
genericnumber1 Posted September 17, 2008 Share Posted September 17, 2008 do $winpath = mysql_real_escape_string("c:\wmpub\WMRoot\MyXfer\Movies"); \ doesn't mean a backslash, it's an escape character, it means "the character after this one does not have its normal meaning" you must escape-the-escape character to make it a backslash \\. mysql_real_escape_string() will do this (along with some other escapes to make queries safe) Link to comment https://forums.phpfreaks.com/topic/124581-solved-inserting-a-path-into-mysql/#findComment-643483 Share on other sites More sharing options...
phatgreenbuds Posted September 17, 2008 Author Share Posted September 17, 2008 That nailed it...thanks a ton... Link to comment https://forums.phpfreaks.com/topic/124581-solved-inserting-a-path-into-mysql/#findComment-643489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.