Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Confused: Warning: Cannot use a scalar value as an array

Featured Replies

Ok im stumped and thats why im here, i have a form with 6 images to upload. I have done these in arrays to save code. This all works but i noticed with errors turned on it brings up Warning: Cannot use a scalar value as an array in *blah* on line 61;

 

heres the code

 

 

LOTS OF OTHER CODE UP HERE

$imgs = array("1", "2", "3", "4", "5", "6");
foreach($imgs as $imgnum){
if (!empty($_FILES["picture".$imgnum])&∅($error)){
$ext = strtolower(strrchr($_FILES["picture".$imgnum]['name'], '.'));
$type = $_FILES["picture".$imgnum]['type'];
$filesize = filesize($_FILES["picture".$imgnum]['tmp_name']);
if (empty($_POST["label".$imgnum])){ $error["label".$imgnum] = "You must add a title for your image."; }
else if ($filesize >= $maxfilesize){ 
$error["pic"] = $lang['pictures_error_maxsize']; }

LOTS MORE CODE DOWN HERE

 

 

 

any pointers?

Edited by JSweete

Interesting.....!

 

You have no reply yet....

 

Good Luck then...

Ok im stumped and thats why im here, i have a form with 6 images to upload. I have done these in arrays to save code. This all works but i noticed with errors turned on it brings up Warning: Cannot use a scalar value as an array in *blah* on line 61;

 

heres the code

 

 

LOTS OF OTHER CODE UP HERE

$imgs = array("1", "2", "3", "4", "5", "6");
foreach($imgs as $imgnum){
if (!empty($_FILES["picture".$imgnum])&∅($error)){
$ext = strtolower(strrchr($_FILES["picture".$imgnum]['name'], '.'));
$type = $_FILES["picture".$imgnum]['type'];
$filesize = filesize($_FILES["picture".$imgnum]['tmp_name']);
if (empty($_POST["label".$imgnum])){ $error["label".$imgnum] = "You must add a title for your image."; }
else if ($filesize >= $maxfilesize){ 
$error["pic"] = $lang['pictures_error_maxsize']; }

LOTS MORE CODE DOWN HERE

 

 

 

any pointers?

 

The error message you get accures when you treat something as an array , which is not an array, but an integer, or maybe something with a value null.

 

I am not sure, but try to check if a file is uploaded like this:

if($_FILES["picture".$imgnum]['error']==0)
{
// your code comes here
}

  • 2 weeks later...
  • Author

The error message you get accures when you treat something as an array , which is not an array, but an integer, or maybe something with a value null.

 

I am not sure, but try to check if a file is uploaded like this:

if($_FILES["picture".$imgnum]['error']==0)
{
// your code comes here
}

 

it was exactly that, i had miss declared some error report variables, all sorted now thanks for your help :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.