spoco Posted November 18, 2008 Share Posted November 18, 2008 I was able to get a page to write to a database, now I'm trying to get a page that will display all of the records. Why is this code not working? <?php require_once("../databaseconn.php"); ?> <?php mysql_select_db('training', $databaseconn); $SQLstring = "SELECT * FROM evaluation"; $QueryResult = mysql_query($SQLstring, $databaseconn) or die(mysql_error(Unable to execute query.)); $Row = mysql_fetch_row ($QueryResult); echo "<p><strong>1a</strong>" {$Row[0}}<br />"; echo "<strong>1b</strong>" {$Row[1}}<br />"; echo "<strong>1c</strong>" {$Row[2}}<br />"; echo "<strong>2a</strong>" {$Row[3}}<br /></p>"; ?> </div></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/133225-new-to-mysql-day-2/ Share on other sites More sharing options...
Mchl Posted November 18, 2008 Share Posted November 18, 2008 Because you have unpaired quotes (in last 4 ecgo lines). Use editor with code highlightning (Notepad++ is a popular one for Windows). Quote Link to comment https://forums.phpfreaks.com/topic/133225-new-to-mysql-day-2/#findComment-692877 Share on other sites More sharing options...
spoco Posted November 18, 2008 Author Share Posted November 18, 2008 Okay. fixed that, but still no results. blank page. <?php require_once("../databaseconn.php"); ?> <?php mysql_select_db('training', $databaseconn); $SQLstring = "SELECT * FROM evaluation"; $QueryResult = mysql_query($SQLstring, $databaseconn) or die(mysql_error(Unable to execute query.)); $Row = mysql_fetch_row ($QueryResult); echo "<p><strong>1a</strong>: {$Row[0}}<br />"; echo "<strong>1b</strong>: {$Row[1}}<br />"; echo "<strong>1c</strong>: {$Row[2}}<br />"; echo "<strong>2a</strong>: {$Row[3}}<br /></p>"; ?> </div></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/133225-new-to-mysql-day-2/#findComment-692885 Share on other sites More sharing options...
fenway Posted November 18, 2008 Share Posted November 18, 2008 Make sure error reporting is turned in php... Quote Link to comment https://forums.phpfreaks.com/topic/133225-new-to-mysql-day-2/#findComment-692904 Share on other sites More sharing options...
Mchl Posted November 18, 2008 Share Posted November 18, 2008 You should enable error reporting. I can see at least one place that should give you a warning. To enable error reporting add these two lines at the beginning of your script ini_set("display_errors","1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/133225-new-to-mysql-day-2/#findComment-692905 Share on other sites More sharing options...
revraz Posted November 18, 2008 Share Posted November 18, 2008 Missing Quotes here or die(mysql_error(Unable to execute query.)); Quote Link to comment https://forums.phpfreaks.com/topic/133225-new-to-mysql-day-2/#findComment-692908 Share on other sites More sharing options...
xtopolis Posted November 19, 2008 Share Posted November 19, 2008 <?php echo "<strong>1b</strong>: {$Row[1}}<br />"; ?> That syntax doesn't look right, shouldn't it have a closing ] <?php echo "<strong>1b</strong>: {$Row[1]}<br />"; ?> Could be mistaken, I don't use that method. Quote Link to comment https://forums.phpfreaks.com/topic/133225-new-to-mysql-day-2/#findComment-693166 Share on other sites More sharing options...
Mchl Posted November 19, 2008 Share Posted November 19, 2008 Yes it should be. It's an array after all. Quote Link to comment https://forums.phpfreaks.com/topic/133225-new-to-mysql-day-2/#findComment-693306 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.