2
Contributors
6
Replies
41
Views
3 Years
Discussion Span
Last Post by davy_yg
0

Hi, before the undefined index notice there is:

unable to select dataid is empty

but this is no where in the above code, it could be related to the error. Also, do not mix backslash and slash as here:

c:\xampp\xampp\htdocs\rustoleum/photocms/

And if you want to use it, at least escape it, because the backslash is an escape character, so:

# escaped:
"c:\\xampp\\xampp\\htdocs\\rustoleum\\photocms\\"

# or with single quotes:
'c:\\xampp\\xampp\\htdocs\\rustoleum\\photocms\\'

# better with slashes:
'c:/xampp/xampp/htdocs/rustoleum/photocms/'

Docs:

0

ok I fix that one. This time, when I try to upload a picture this error appears:

unable to select dataid is emptyDuplicate entry '0' for key 'post_ID'

Why is it?

0

Duplicate entry '0' for key 'post_ID'

it happens because post_ID is probably a unique key, in the static_page table, but not the primary key, otherwise the message would be a bit different:

ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'

instead of:

ERROR 1062 (23000): Duplicate entry '0' for key 'post_ID'

it happens because post_ID misses the auto_increment attribute: for this reason, to the first inserted image will be assigned a value of 0, when you try to add a new image you get the Duplicate entry '0' error.

You can fix that by adding the attribute to the column:

alter table static_page modify post_ID int unsigned not null auto_increment unique;
0

ok, I fixed that one. Now, I have another error:

unable to select dataid is empty
Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\rustoleum\administrator\input_gallery.php on line 137

line 137: $upload_exts = end(explode(".", $_FILES["image"]["name"]));

0

The unable to select dataid error is probably in the included file:

include('../includes/koneksi.php');

Regarding line 137 this problem is caused by end() because the first argument must be an array:

This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.

Ref. http://www.php.net/end

So, save the result of explode() in a variable and then use end() against this variable, for example:

$exts = explode('.', $_FILES["image"]["name"]);
$extension = end($exts);
0

Now, I receive this message:

unable to select dataid is empty
Invalid file
Data telah tersimpan. (Data is saved)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.