Lassie Posted December 16, 2006 Share Posted December 16, 2006 I have just upgrade from mysql 3.23.53 to 4.1.9 and php 4.2.2 to 4.3.10I have cart application that worked before but now gives me some warningshere is an exampleNotice: Use of undefined constant product_id - assumed 'product_id' in c:\program files\easyphp1-8\www\e_cart7\index.php on line 45the 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. Quote Link to comment Share on other sites More sharing options...
taith Posted December 16, 2006 Share Posted December 16, 2006 [code]$row{product_id} --> $row['product_id'][/code]{} treat it as a defined varaiable, not as a column name. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 16, 2006 Share Posted December 16, 2006 When you use associative arrays (arrays with strings as the keys) you [b][u]should[/u][/b] wrap them in quotes (as shown by taith) otherwise PHP will think you are using a constant. Quote Link to comment Share on other sites More sharing options...
taith Posted December 16, 2006 Share Posted December 16, 2006 i may also not that as it [u][b]should[/b][/u] it is not mandatory... some later versions of php allow for it. Quote Link to comment Share on other sites More sharing options...
Lassie Posted December 17, 2006 Author Share Posted December 17, 2006 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 onand 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 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 17, 2006 Share Posted December 17, 2006 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. Quote Link to comment Share on other sites More sharing options...
Lassie Posted December 17, 2006 Author Share Posted December 17, 2006 Ok. Will do Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.