underknown Posted October 11, 2010 Share Posted October 11, 2010 Alright, so I've been building code in my computer science class (no prior PHP experience before approx. this past week). We're just importing the first array from a MySQL database, and it's not working for me. Our teacher included a broken-linked image that apparently tells us how to close the connection, but being unable to see it....I can't. I'm not sure exactly what's not working, but here's my current code: <html> <body> <?php echo "<h1>This is a test. Does this script insert values?</h1>"; // Connect to the database $dbc = mysqli_connect('localhost', 'root', 'root', 'myrent-a-movie-final') or die('Error connecting to MySQL server.'); // Build the query $query = "SELECT * FROM customers"; $result = mysqli_query($dbc, $query) or die('Error querying database.'); //Display Results through Array Loop While ($row = mysqli_fetch_array($result)) { echo $row['surname']; echo $row['given_name']; echo $row['address']; echo $row['city']; echo $row['province']; echo $row['postal_code']; echo $row['phone_number']; echo $row['email']; // Close the database connection mysqli_close($dbc); ?> </body> </html> And here is my accompanying error message: "Parse error: syntax error, unexpected $end in Z:\www\mysql_basics\view_data.php on line 32" Quote Link to comment https://forums.phpfreaks.com/topic/215653-coding-assistance/ Share on other sites More sharing options...
awpti Posted October 11, 2010 Share Posted October 11, 2010 you're missing a } just above the mysqli_close call. Quote Link to comment https://forums.phpfreaks.com/topic/215653-coding-assistance/#findComment-1121273 Share on other sites More sharing options...
underknown Posted October 12, 2010 Author Share Posted October 12, 2010 THANK YOU so much. If I could bother someone for a bit of additional assistance, how would I make those display in the same rows that they're in in the database? Do I just need a break after all the echoes? Quote Link to comment https://forums.phpfreaks.com/topic/215653-coding-assistance/#findComment-1121277 Share on other sites More sharing options...
underknown Posted October 12, 2010 Author Share Posted October 12, 2010 Basically wondering how to format the individual lines of data, so each entry is displayed on its own line with spaces between? Quote Link to comment https://forums.phpfreaks.com/topic/215653-coding-assistance/#findComment-1121293 Share on other sites More sharing options...
ignace Posted October 12, 2010 Share Posted October 12, 2010 insert: echo '<p>'; before the first echo in the while and insert: echo '</p>'; just before the closing } Quote Link to comment https://forums.phpfreaks.com/topic/215653-coding-assistance/#findComment-1121417 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.