stubyh Posted November 2, 2006 Share Posted November 2, 2006 Hi I am currently having problems with this line in the code below[color=red]echo "<a href=\"".$row[url]."\"><img src=\"/banner/bannerimages/".$row[image]."\" alt=\"".$row[alt_title]."\" border=\"0\"></a>"; [/color] what I am getting isNotice: Use of undefined constant url - assumed 'url' in c:\websites\banner\index3.php on line 67Notice: Use of undefined constant image - assumed 'image' in c:\websites\banner\index3.php on line 67Notice: Use of undefined constant alt_title - assumed 'alt_title' in c:\websites\banner\index3.php on line 67and then the banner is displayed normally with correct url, image and alt_titleyour help would be much appreciatedcode bellow formatting has been removed (tables):-thanks stubyh[code]<?php // get the data from the database require_once('Connections/banners.php'); // Number of records to show per page:$display = 10;// Determine how many pages there are. if (isset($_GET['np'])) { // Already been determined. $num_pages = $_GET['np'];} else { // Need to determine. $get_ids_sql = "SELECT id, link AS url, alt_title, image FROM banners WHERE status = 'on'"; $get_ids_res = mysql_query ($get_ids_sql); $get_ids_array = array(); $row = mysql_fetch_array($get_ids_res, MYSQL_NUM); $num_records = $row[0]; // Calculate the number of pages. if ($num_records > $display) { // More than 1 page. $num_pages = ceil ($num_records/$display); } else { $num_pages = 1; } } // End of np IF. // create the page for realwhile ($row = mysql_fetch_array($get_ids_res, MYSQL_ASSOC)) { echo "<a href=\"".$row[url]."\"><img src=\"/banner/bannerimages/".$row[image]."\" alt=\"".$row[alt_title]."\" border=\"0\"></a>";}// Make the links to other pages, if necessary.if ($num_pages > 1) { echo '<br /><p>'; // Determine what page the script is on. $current_page = ($start/$display) + 1; // If it's not the first page, make a Previous button. if ($current_page != 1) { echo '<a href="view_users.php?s=' . ($start - $display) . '&np=' . $num_pages . '">Previous</a> '; } // Make all the numbered pages. for ($i = 1; $i <= $num_pages; $i++) { if ($i != $current_page) { echo '<a href="view_users.php?s=' . (($display * ($i - 1))) . '&np=' . $num_pages . '">' . $i . '</a> '; } else { echo $i . ' '; } } // If it's not the last page, make a Next button. if ($current_page != $num_pages) { echo '<a href="view_users.php?s=' . ($start + $display) . '&np=' . $num_pages . '">Next</a>'; } echo '</p>'; } // End of links section.?>[/code] Link to comment https://forums.phpfreaks.com/topic/25935-problem-with-a-while-statement-and-mysql/ Share on other sites More sharing options...
trq Posted November 2, 2006 Share Posted November 2, 2006 Non numeric array indexes need quotes. eg $array['value'] not $array[value].[code=php:0]echo "<a href=\"".$row['url']."\"><img src=\"/banner/bannerimages/".$row['image']."\" alt=\"".$row['alt_title']."\" border=\"0\">[/url]";[/code] Link to comment https://forums.phpfreaks.com/topic/25935-problem-with-a-while-statement-and-mysql/#findComment-118444 Share on other sites More sharing options...
stubyh Posted November 2, 2006 Author Share Posted November 2, 2006 thankshave tried that and thisecho "<a href=\""{$row['url']}"\"><img src=\"/banner/bannerimages/"{$row['image']}"\" alt=\""{$row['alt_title']}"\" border=\"0\"></a>";but still getting same resultsmod -also getting Parse error: parse error, unexpected '{', expecting ',' or ';' in c:\websites\banner\notables.php on line 42 Link to comment https://forums.phpfreaks.com/topic/25935-problem-with-a-while-statement-and-mysql/#findComment-118449 Share on other sites More sharing options...
trq Posted November 2, 2006 Share Posted November 2, 2006 [code=php:0]echo "<a href=\"{$row['url']}\"><img src=\"/banner/bannerimages/{$row['image']}\" alt=\"{$row['alt_title']}\" border=\"0\">[/url]";[/code] Link to comment https://forums.phpfreaks.com/topic/25935-problem-with-a-while-statement-and-mysql/#findComment-118453 Share on other sites More sharing options...
stubyh Posted November 2, 2006 Author Share Posted November 2, 2006 Thanks very much that works. :) Link to comment https://forums.phpfreaks.com/topic/25935-problem-with-a-while-statement-and-mysql/#findComment-118458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.