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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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