Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now