Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

MySQL update works in Firefox and Chrome but not in IE

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

MySQL update works in Firefox and Chrome but not in IE

Postby peterk900 » Sat Jul 06, 2013 9:00 am

I have code which updates a MySQL db getting data from the explode function. The problem fields are two dates which are handled as strings within the php code. The MySQL fields for these dates are varchar.

The code correctly updates the two date fields when run in Firefox or Chrome. However in IE the string value used to update is prefixed with what looks like time data - 00:0-07-11 where the value should be 2013-07-11 - format being Y,m,d.

There are no problems with the SQL update in IE when I assign the values for the string directly
Code: Select all
$startdate = "2013-07-11"


I've tried various hacks to remove any spurious characters ltrim, rtrim , substr. The problem occurs with IE 10 and earlier versions.


Here's part of the code dealing with one of the dates..
Code: Select all
$myid = $_POST["myid"];
$mytitle = $_POST["name"];


if  (empty($_POST["end"]))
   {
   fwrite($fh, " no end value\n");
   }
   else
   {
   $date4 = explode(" ", $_POST["end"]);
   fwrite($fh, $_POST["end"]."   postend\n");

   switch ($date4[1])

    {
    case "Jan":
      $month = "01";
      break;
    case "Feb":
      $month = "02";
      break;
    case "Mar":
      $month = "03";
      break;
    case "Apr":
      $month = "04";
      break;
    case "May":
      $month = "05";
      break;
    case "Jun":
      $month = "06";
      break;
    case "Jul":
      $month = "07";
      break;
    case "Aug":
      $month = "08";
      break;
    case "Sep":
      $month = "09";
      break;
    case "Oct":
      $month = "10";
      break;
    case "Nov":
      $month = "11";
      break;
    case "Dec":
      $month = "12";
      break;
   
    default:
     // ------------------
    }
   
   $year = date4[3];
   $year = ltrim(rtrim($year));
   
   $month = ltrim(rtrim($month));
   $day =  date4[2];
   $day = ltrim(rtrim($day));


   $ieend = '"'.$year."/".$month."/".$day.'"';

   }


Here's the update code..
Code: Select all
$con=mysqli_connect("","","","");

   // Check connection
    if (mysqli_connect_errno($con))
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();

      }
   
   
   $NewStart = $iestart;  //"08/17/2013";
   $NewEnd = $ieend;  //"08/19/2013";
   $MyId = $myid;    
   

   $stringData = "UPDATE tblCalendar101 SET start = '" . $NewStart . "', End = '" . $NewEnd . "', Title = '" . $mytitle . "' WHERE id = " . $MyId ;

   mysqli_query($con, $stringData);

 mysqli_close($con);


Any suggestions over what to do would be much appreciated.
Thanks.
peterk900
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Jul 06, 2013 8:34 am

Re: MySQL update works in Firefox and Chrome but not in IE

Postby peterk900 » Sun Jul 07, 2013 4:32 am

The data source for the dates is a POST string. The problem is that the format of the string is different in IE compared to the other browsers.

Firefox/Chrome
Code: Select all
Thu Jul 04 2013 00:00:00 GMT+0100 (GMT Standard Time)


IE
Code: Select all
Fri Jul 5 00:00:00 UTC+0100 2013


The key differences are single digit days - not 0 padded - and a different location for the year. Sortable with a bit of string manipulation. It would be better to use a Unix Timestamp - but I'm not sure yet how I get this from the FullCalendar JQuery plug in.
peterk900
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Jul 06, 2013 8:34 am

Re: MySQL update works in Firefox and Chrome but not in IE

Postby johnj » Tue Jul 09, 2013 12:20 am

for this, read about the Date Object in js
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: MySQL update works in Firefox and Chrome but not in IE

Postby johnj » Tue Jul 09, 2013 12:21 am

johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron