Another PDO problem

  • (6 Pages)
  • +
  • « First
  • 4
  • 5
  • 6

77 Replies - 1826 Views - Last Post: 07 December 2013 - 04:03 AM Rate Topic: ***-- 2 Votes

#76 chris98  Icon User is offline

  • D.I.C Addict

Reputation: 34
  • Posts: 861
  • Joined: 06-July 13

Re: Another PDO problem

Posted 01 November 2013 - 05:04 AM

Thank you for your help.
Was This Post Helpful? 0
  • +
  • -

#77 chris98  Icon User is offline

  • D.I.C Addict

Reputation: 34
  • Posts: 861
  • Joined: 06-July 13

Re: Another PDO problem

Posted 07 December 2013 - 02:37 AM

I have just changed servers, and I have updated my DB accordingly. I have changed all my PDO objects (including in most of the files), and I get this error which never appeared before:

Warning: explode() [function.explode]: Empty delimiter in /home/****/lister.php on line 149



It has something to do with this, as whenever I remove it it works:

<?php
$cutted = substr($row['size'], 0, 40) . ''; // get 40 chars and append ....
$str = "".$row['size']."";
$parts = explode("", $str);
print $parts[0] . ' ' .$parts[1] . ' ' .$parts[2] . ' ' .$parts[3] . ' ' .$parts[4] . '....';
?>


Was This Post Helpful? 0
  • +
  • -

#78 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3555
  • View blog
  • Posts: 10,335
  • Joined: 08-June 10

Re: Another PDO problem

Posted 07 December 2013 - 04:03 AM

as the error message states, you need a non-empty delimiter for explode() to work properly.

besides that, line #3 is absolutely superfluous. PHP can do type conversion of its own, if necessary. and if you need explicit casting, use the appropriate syntax for it ((string) $row['size']).

and another one, line #5 should be done using implode() and while were at that, the whole business could most probably done way easier with a replacement function (Id stab a guess at preg_replace()).
Was This Post Helpful? 0
  • +
  • -

  • (6 Pages)
  • +
  • « First
  • 4
  • 5
  • 6