Jump to content

ambition13

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ambition13's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, I have narrowed the problem down further. The error is coming from the following code: function update_fav_people($fav_people) {         global $_USER;         $DELETE = "DELETE FROM favorites WHERE user_id = '$_USER[user_id]' and fav_type = '2'";         $dresult = mysql_query($DELETE);         if ($fav_people) {                 natksort($fav_people);                 foreach ($fav_people as $name=>$more) {                         if ($more) {                                 foreach ($more as $people_id=>$value) {                                         if ($people_id != 0) {                                                 $INSERT = "INSERT INTO favorites (user_id, fav_type, id) VALUES ('$_USER[user_id]', '2', '$people_id')";                                                 echo $INSERT;                                                 $iresult = mysql_query($INSERT);                                         }                                 }                         }                 }                 $UPDATE = "UPDATE users SET fav_people = '" . addslashes(serialize($fav_people)) . "' WHERE user_id = '$_USER[user_id]'";                 echo $UPDATE;                 $uupdate = mysql_query($UPDATE);         } else {                 $UPDATE = "UPDATE users SET fav_people = '' WHERE user_id = '$_USER[user_id]'";                 $uupdate = mysql_query($UPDATE);         } } When running the UPDATE code, it inserts extra data.  The Mysql record then looks like this:  a:5:{i:1;s:13:"Julia Roberts";i:2;s:0:"";i:3;s:0:"";i:4;s:0:"";s:13:"Julia Roberts";a:1:{i:8483;a:2:{s:9:"birthdate";s:10:"1967-10-28";s:5:"image";s:2:"mf";}}} It should just look like this: a:1:{s:13:"Julia Roberts";a:1:{i:8483;a:2:{s:9:"birthdate";s:10:"1967-10-28";s:5:"image";s:2:"mf";}}} Again I inherited this code and am just trying to make it work.  How can I rewrite the above function so that it doesn't insert the extra data? Thanks again for all the help.
  2. Yes, an included file.  I inherited this code so I am not sure of all the naming conventions yet. Here is the output of the print_r: Array ( [1] => Tom hanks [2] => [3] => [4] => [Tom Hanks] => Array ( [16937] => Array ( [birthdate] => 1956-07-09 [image] => mf ) ) )
  3. It is being defined in another file with this: $fav_people = unserialize($_USER[fav_people]); Neither server has register globals turned on (including the one where the code works).
  4. Hello, I have the same files on 2 servers, one server is running php 4.3.2 and the code works.  The newer server is running 4.4.3 and the same code does not work. The code is as follows:                 foreach ($fav_people as $name=>$more) {                         foreach ($more as $people_id=>$value) {                                 if ($people_id != 0) {                                         $INSERT = "INSERT INTO favorites (user_id, fav_type, id) VALUES ('$_USER[user_id]', '2', '$people_id')";                                         $iresult = mysql_query($INSERT);                                 }                         } On the newer server, it gives the following error: Warning: Invalid argument supplied for foreach() in _db_functions.php on line 157 This warning shows up 4 times for that line.  Anyone have any suggestions on how to troubleshoot this? Thanks in advance. ambition13
×
×
  • 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.