Jump to content

Loosing characters when posting to MySql


petenetman

Recommended Posts

Say I have:

$vSQL .= "Message=" . chr(34) . $Message . chr(34) .   and the $Message contains \\myserver\inetpub\www\

When I post to MySql I get \myserverinetpubwww I have no idea why. I know the chr(34) takes out the single quotes around text in the $Message. All I want to do is to post to MySql whatever is in the text field.

Link to comment
https://forums.phpfreaks.com/topic/88546-loosing-characters-when-posting-to-mysql/
Share on other sites

I must be having a little 'Thicko' day - Sorry

Let me explain a little better....

This code is as follows:

if ( $JobNo > 0) {

 

$vSQL = "UPDATE worklog SET RepBy='" . $RepBy . "', Contact='" . $Contact . "', ";

$vSQL .= "Message=" . chr(34) . $Message . chr(34) . ", Handled='" . $Handled . "', Detail=" . chr(34) . $Detail . chr(34) . ", ";

$vSQL .= "CompletedIT='" . $CompletedIT . "', Priority='" . $Priority . "', JobGroup='" . $JobGrp . "'

, ";

$vSQL .= "CatType='" . $CatType . "', CatDate='" . $CatDate . "' ";

$vSQL .= "WHERE JobNo=" . $JobNo;

 

The $Message field and the $Detail field can contain any text character. After moving from a UNIX box to windows I had to change the $message to chr(34) as MySql fell over the something like 'ReadMe' as used in the test field. I am trying to find a string that goes around both $fields so MySql can handle the update.

 

Thanks Pete

if ( $JobNo > 0) {

  $Message = mysql_real_escape_string($Message);
  $Detail = mysql_real_escape_string($Detail);

  $vSQL = "UPDATE worklog SET RepBy='" . $RepBy . "', Contact='" . $Contact . "', ";
  $vSQL .= "Message=" . chr(34) . $Message . chr(34) . ", Handled='" . $Handled . "', Detail=" . chr(34) . $Detail . chr(34) . ", ";
  $vSQL .= "CompletedIT='" . $CompletedIT . "', Priority='" . $Priority . "', JobGroup='" . $JobGrp . "'
, ";
  $vSQL .= "CatType='" . $CatType . "', CatDate='" . $CatDate . "' ";
  $vSQL .= "WHERE JobNo=" . $JobNo;

I'm afraid

 

  $Message = mysql_real_escape_string($Message);

  $Detail = mysql_real_escape_string($Detail);

 

Did not help. Neither did it stop my page from working. Would it be something to do with the version of PHP that I've got installed? It's v4

 

Pete

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.