Jump to content

Undefined constant


Lassie

Recommended Posts

I have just upgrade from mysql 3.23.53 to 4.1.9 and php 4.2.2 to 4.3.10
I have cart application that worked before but now gives me some warnings
here is an example
Notice: Use of undefined constant product_id - assumed 'product_id' in c:\program files\easyphp1-8\www\e_cart7\index.php on line 45

the code is

//get featured books

$connection = db_connect();
  $query = "select * From products WHERE Featured='1' Order by cat_id";
  $result = mysql_query($query);
  if (!$result)
  return false;
  $num_cats = mysql_num_rows($result);
  if ($num_cats ==0)
  return false;
 
echo '<td>';/* set cell for contents within overall table*/
echo'<div id="contents">';
echo'<table id="contents" width="700" border="1" cellpadding="0">';
echo"<caption>Welcome to e-Books4U electronic Book store</caption>";
echo'<thead><tr><td bgcolor="gray" colspan="5" ><h6>This Months Featured e-Books</h6></td></tr>
</thead>';
  $i=0;
  $size=3;
  echo "<tbody>";
    echo "<tr>";
  while ($row = mysql_fetch_array($result,MYSQL_ASSOC))  #38
  {
    /* display picture  */
   
    echo "<td><a href='./images/{$row['pix']}' border='0'>
        <img src= './images/{$row['pix']}' border='0'
              width='100' height='80'></a></br>";

/* display row for each featured book */
$url= 'show_book.php?product_id='.($row{product_id});  [color=red]//line 45[/color]   
  $title = $row['title'];
    do_html_url($url,$title);
    echo "ONLY</br>";
    echo "£{$row['price']}</td>";
    $i++;
   
    if($i==$size)
{
  echo "</tr><tr>";
 
  $i=0;
}

I have imported the database and as far as i can see that is ok.
Can any one show me where to look please.
Link to comment
Share on other sites

Thanks for that guys> i will try and get my head around it.
Incidently, I noticed that in my original set up register globals were set to on
and in the new config they are set to off.
I understand this has a security implication, but would it also be a cause of the warnings?
If I turn register globals on would that cure it?
lassie
Link to comment
Share on other sites

Turning regsiter_globals on will not "cure it". register_globals affects super global variables ($_POST, $_GET, $_SERVER etc). You should not turn this setting on.

The message you are getting is a syntax issue, nothing will cure it from the settings in the php.ini, however you can get PHP to ignore notices by lowering the error_reporting level but this is not recommended. The only way to cure it is make the changes taith suggested.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.