note 34038 added to function.is-int
| From: | gabe at websaviour dot com | Date: | Mon, 14 Jul 2003 16:08:41 +0000 |
| Subject: | note 34038 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52085@lists.php.net to get a copy of this message | ||
Although this can be inferred from the documentation, beware of numeric strings. I ran into the
problem in a MySQL app where I would either SELECT an INT PRIMARY KEY or INSERT a new record and use
mysql_insert_id() to get the KEY before continuing onto the new section.
I used is_int() to make sure the subsequent queries wouldn't break when using the key variable.
Unfortunately I failed to realize that while mysql_insert_id() returns an int, mysql_result()
always returns a string even if you are SELECTing from an INT field.
Spent at least 30 minutes trying to figure out why existing records weren't getting linked, but
new records would link fine. I ended up using intval() on mysql_result() to make sure subsequent
queries still always work.
----
Manual Page -- http://www.php.net/manual/en/function.is-int.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34038
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34038&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34038&report=yes