Topic: Error Adding New Item or Editing Existing Item

When I try and add a new item or edit an existing item all I get is a red triangle at the top of the form.  In the error log I get the following entries:

[02-Apr-2014 20:48:16 America/New_York] 1:crspencer:items.php:78: in_array() expects at least 2 parameters, 1 given
[02-Apr-2014 20:48:16 America/New_York] 1:crspencer:items.php:78: strtoupper() expects exactly 1 parameter, 2 given


Any help would be much appreciated!!

Re: Error Adding New Item or Editing Existing Item

Nice catch.

Replace the file inventory/manage/items.php with the file in the attachment in this post.

Joe - please fix it in the Hg repo - attachment has the patch as well.

Post's attachments

items_patch.zip 5 kb, 9 downloads since 2014-04-03 

You don't have the permssions to download the attachments of this post.

Re: Error Adding New Item or Editing Existing Item

@apmuthu

Your solution didn't accept jpg files in my environment.

The elsif sentence was originally badly written.

Your solution has been changed from 

elseif (@strtoupper(substr(trim($_FILES['pic']['name']), @in_array(strlen($_FILES['pic']['name']) - 3, array('JPG','PNG','GIF')))))
     
to a much more reliable sentence

elseif (!in_array(strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)), array('JPG','PNG','GIF')))

Please download the file items.php1. Rename it to items.php and replace it in /inventory/manage folder.

HG repository willbe updated in a while.

/Joe

Post's attachments

items.php1 16.3 kb, 6 downloads since 2014-04-03 

You don't have the permssions to download the attachments of this post.

Re: Error Adding New Item or Editing Existing Item

After completing that fix, I still get the red triangle but no longer get error messages in the log.  When I try and change an existing item, I get the red triangle and this in the error log:

[03-Apr-2014 12:55:27 America/New_York] 1:crspencer:connect_db.inc:89: mysql_fetch_array() expects parameter 1 to be resource, boolean given
[03-Apr-2014 12:55:27 America/New_York] 1:crspencer:connect_db.inc:89: mysql_fetch_array() expects parameter 1 to be resource, boolean given
[03-Apr-2014 12:56:02 America/New_York] 1:crspencer:connect_db.inc:89: mysql_fetch_array() expects parameter 1 to be resource, boolean given
[03-Apr-2014 12:56:02 America/New_York] 1:crspencer:connect_db.inc:89: mysql_fetch_array() expects parameter 1 to be resource, boolean given

Re: Error Adding New Item or Editing Existing Item

Which versions are you running? MySql, PHP and OS.

/Joe

6 (edited by apmuthu 04/04/2014 04:35:18 am)

Re: Error Adding New Item or Editing Existing Item

@joe: Thankyou Joe, when codeing it, I was thinking only of the function arguments and not the order...

@crspencer: Yes, it will now have to be your versions of PHP/MySQL or their implementation in the Server OS used. Ref: MySQL v5.5.13 Deprecated use.

Re: Error Adding New Item or Editing Existing Item

PHP = 5.3.27
MySQL = 5.6.14 Community
OS = Windows Server 2012 R2 x64

It has all worked fine in the past, this just started happening and I can't think of anything that has changed.

Re: Error Adding New Item or Editing Existing Item

Try to rollback to a version before PHP 5.5.x and revert with the results.
Hope you are using MySQL_PDO or MySQLi instead of MySQL driver, else try with the MySQLi driver even without changing the PHP version.