Jump to content

[SOLVED] Inserting a path into MySQL


phatgreenbuds

Recommended Posts

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

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)

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.