Solved

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

Posted on 2003-11-08
3
28,084 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 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