ID:               35127
 User updated by:  sketchdude at gmail dot com
 Reported By:      sketchdude at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         MySQL related
 Operating System: WindowsXP, Linux
 PHP Version:      4.4.1
 New Comment:

My own bad variable. Sorry for wasting your time.


Previous Comments:
------------------------------------------------------------------------

[2005-11-06 16:12:08] sketchdude at gmail dot com

Description:
------------
The cat_id fields fails to update after an insert and select query.
(see sql example below)

/*
use thisexample;

CREATE TABLE example (
  example_id int unsigned not null auto_increment,
  cat_id int unsigned not null,
  name varchar(35) not null,
  total tinyint unsigned not null,
  PRIMARY KEY (example_id)
);

INSERT INTO example VALUES (1,1,'One',1);
INSERT INTO example VALUES (2,2,'Two',0);
INSERT INTO example VALUES (3,3,'Three',0);
INSERT INTO example VALUES (4,4,'Four',0);
*/

Reproduce code:
---------------
$name = 'Five';
$query = "INSERT INTO example (example_id, cat_id, name, total) VALUES
('', 0, '$name', 0)";
if (!$result = mysql_query($query)) {
  print "Insert query failed ($query) : " . mysql_error();
  exit;
}
$query = "SELECT example_id AS new_id FROM example WHERE name
='$name'";
if (!$result = mysql_query($query)) {
  print "Select query failed ($query) : " . mysql_error();exit;
}
else {
  $new_id = mysql_fetch_row($result);
  $query = "UPDATE example SET cat_id = '$new_id[0]' WHERE example_id =
'$name'";
  if (!$result = mysql_query($query)) {
    print "Update query failed ($query) : " . mysql_error(); exit;
  }
  else {
    print "Script ran successfully! New cat_id = " . $new_id[0];
  }
}

Expected result:
----------------
The problem is the third query: cat_id field should be updated to 5, or
else the script should die and print out the query.

Actual result:
--------------
The script executes successfully, but the cat_id field remains at 0.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35127&edit=1

Reply via email to