PHP and MySQL help

My prof gave out this extra credit assignment, but we haven’t even learned PHP! He set up a MySQL host and wants us to make a “site” that uses PHP to let people browse products and leave reviews on the products. We have to store the products on mySQL. Which, we also haven’t learned.

I want these extra credit points, but jeez!

Here’s what I have now, after going through php tutorials for the last week, and it’s just displaying a big, fat blank white page. Ugh.

// Connects to your Database
$connection = mysql_connect(“sqlHost”, “idname”, “password”);
mysql_select_db(“databaseName”, $connection);
$sql = “SELECT * FROM tableName”;
$result = mysql_query($sql, $connection) or die(mysql_error());

while ($resultArray = mysql_fetch_array($result)){
$id = $resultArray[‘Name’];
echo $id;


Then I guess this will be your first lesson in PHP debugging. And for what it’s worth, learning to learn is the best quality aside from professional programming concepts, that a developer will get from school. That is probably the only thing that your first hiring manager will be half way impressed with, that you went out, applied what you have learned and taken the initiative to learn something that is not taught at your school. Plus, to put it blunt, that separates you from the rest of the lemmings that are graduating that semester.

Anyway, back to the point, run this and then post your results:

<?php //show all errors error_reporting(E_ALL); ini_set('display_errors', '1'); // Connects to your Database //normally you wouldn't want "mysql_error" in your "or die" statements because you don't want the rest of the world knowing anything about your configuration $connection = mysql_connect("sqlHost", "idname", "password") or die(mysql_error()); mysql_select_db("databaseName", $connection) or die(mysql_error()); $sql = "SELECT * FROM tableName"; $result = mysql_query($sql, $connection) or die(mysql_error()); echo __LINE__ . "
"; //tells you that your script is still running when you see this line number while ($resultArray = mysql_fetch_array($result)){ $id = $resultArray['Name']; echo $id; echo __LINE__ . "
"; } ?>


Sponsor our Newsletter | Privacy Policy | Terms of Service