0

input_image.php

<?php

$result = mysql_query("SELECT * FROM image_upload ORDER BY image_id ASC");

$data = mysql_fetch_array($result);

$banner = $data['image_bn'];

?>

<p><img src="../../images/<?php $banner; ?>"></p>

<?php echo $_SESSION[$banner]; ?>

line 13: Notice: Undefined index: adm_banner.jpg in C:\xampp\htdocs\portal\administrator2\admin\input_image.php on line 76

How to fix the error?

Edited by davy_yg

3
Contributors
14
Replies
84
Views
2 Years
Discussion Span
Last Post by imti321
0

Is line 76 of the input_image.php actually a line 13 in the above snippet? If yes, obviously $_SESSION['adm_banner.jpg'] does not exist. Where is it supposed to be set?

0

yes, line 13 = line 76.

It is set in here:

input_image.php

$banner = $data['image_bn'];
0

Yes, but where is the $_SESSION['adm_banner.jpg'] being set? If you want to echo it you have to set it first.

0
<?php echo $_SESSION[$banner]; ?>

$banner = $data['image_bn'];

$banner = 'adm_banner.jpg'; // it gets from $data['image
_bn'];

0

OK, again. Where is the $_SESSION['adm_banner.jpg'] getting set?

On line 7 in your first post you assign a value from the database to the $banner variable:

$banner = $data['image_bn'];

Then on line 13 you try to echo the $_SESSION[$banner] variable:

echo $_SESSION[$banner];

From the error message it seems that the value of the $banner variable is adm_banner.jpg. So you are essentially trying to echo the $_SESSION['adm_banner.jpg'] variable. The question is: has the $_SESSION['adm_banner.jpg'] been set at all anywhere in the code? It seem not. I guess you have an error in your logic.

Edited by broj1

0

I already place this code on top of:

input_image.php

<?php

session_start();

?>
0

Still does not answer my question: has the $_SESSION['adm_banner.jpg'] been set at all anywhere in the code? Is there a line saying:

$_SESSION['adm_banner.jpg'] = 'something';

or maybe:

$_SESSION[$banner] = 'something';

so you can then echo it. I doubt it is. You probably have an error in your logic. Try to describe what you want to achieve.

Edited by broj1

0

I only except when you print

<?php echo $_SESSION[$banner]; ?>

It prints something like: adm_banner.jpg

instead of: Notice: Undefined index: adm_banner.jpg in C:\xampp\htdocs\portal\administrator2\admin\input_image.php on line 76

Edited by davy_yg

0

Maybe it should be:

<?php echo $_SESSION['banner']; ?>

but I can't tell without seeing the code where you set the $_SESSION value.

0

Well, this is the whole session code part:

<?php

    include('includes/koneksi.php');    

    session_start();
?>

<?php

$result = mysql_query("SELECT * FROM image_upload ORDER BY image_id ASC");

$data = mysql_fetch_array($result);

$banner = $data['image_bn'];

?>

<p><img src="../../images/<?php $banner; ?>"></p>

<?php echo $_SESSION[$banner]; ?>

I still do not understand what's wrong.

0

I already try redefining the value:

$_SESSION[$banner] = $data['image_bn'];

<?php echo $_SESSION[$banner]; ?>

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

Notice: Undefined variable: banner in C:\xampp\htdocs\portal\administrator2\admin\input_image.php on line 72

line 79:Notice: Undefined variable: banner in C:\xampp\htdocs\portal\administrator2\admin\input_image.php on line 79
adm_banner.jpg

0

YOu are giving code i pieaces please post here whole code at once.Along with index file.
ANd also please check this one .
<p><img src="../../images/<?php $banner; ?>"></p>

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.