Jump to content

Coding Assistance


underknown

Recommended Posts

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"

Link to comment
https://forums.phpfreaks.com/topic/215653-coding-assistance/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.