Solved

Notice: Use of undefined constant picture - assumed 'picture' on line 24

Posted on 2003-11-08
3
28,097 Views
Last Modified: 2013-12-13
In the following code I get the error "Use of undefined constant picture - assumed 'picture' on line 24". how can I resolve this error?
<?php

include('include_fns.php');
include('header.php');

$conn = db_connect();


$pages_sql = 'select * from pages order by code';
$pages_result = mysql_query($pages_sql, $conn);

while ($pages = mysql_fetch_array($pages_result)) {

  $story_sql = "select * from stories
                where page = '".$pages['code']."'
                and published is not null
                order by published desc";
  $story_result = mysql_query($story_sql, $conn);
  if (mysql_num_rows($story_result)) {
    $story = mysql_fetch_array($story_result);
    print '<table border="0" width="400">';
    print '<tr>';
    print '<td rowspan="2" width="100">';
(line 24)    if ($story[picture])
      print "<img src=\"resize_image.php?image=$story[picture]\" />";
    print '</td>';
    print '<td>';
    print '<h3>'.$pages['description'].'</h3>';
    print $story['headline'];
    print '</td>';
    print '</tr>';
    print '<tr><td align="right">';
    print '<a href="page.php?page='.$pages['code'].'">';
    print '<font size="1">Read more '.$pages['code'].' ...</font>';
    print '</a>';
    print '</table>';
  }
}

include('footer.php');
?>
0
Comment
Question by:djbell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
DoppyNL earned 125 total points
ID: 9712747
if ($story[picture])

picture is syntacticly a constant here:
it's not a variable, because there is no $ in front of it
it's not a string, because there aren't ' or " around it.

Since it should be a string here, you need to change your code to:

if ($story['picture'])
0
 
LVL 6

Expert Comment

by:DoppyNL
ID: 9716611
Why the b?
not working correctly?
Still having problems?

Could you motivate please?

tnx!
0
 
LVL 1

Expert Comment

by:erevia
ID: 11111517
Hi all

don't forget quotes :-)

just replace
  if ($story[picture])
with :
  if ($story['picture'])

bye
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question