Ok guys I am just diving into the php sql thing so your patience is appreciated.
Ok so I am trying to connect to a database called "Townhomes". I can make the connection to the database fine, but it is not pulling out the table. I spoke with my host they said there is no remote access restrictions on their side, I should be able to connect and retreive the data. So here is my code:
So i'm hanging up at // Select the Townhomes database ..
Any ideas?
---------------------------------------------
Ok so I am trying to connect to a database called "Townhomes". I can make the connection to the database fine, but it is not pulling out the table. I spoke with my host they said there is no remote access restrictions on their side, I should be able to connect and retreive the data. So here is my code:
Code:
<?php
// Connect to the database server
$dbcnx = @mysql_connect("orlandomediasolutions.com", "dbname", "pass");
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" ); exit(); }
// Select the Townhomes database
if (! @mysql_select_db("dbname") ) {
echo( "<P>Unable to locate the dbname " .
"database at this time.</P>" ); exit(); }
?>
<P> Here are all the Townhomes in our database: </P>
<?php // Request the Name of all the Townhomes
$result = mysql_query(
"SELECT Name FROM Townhomes");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit(); }
// Display the Name of each Townhome in a paragraph
while ( $row = mysql_fetch_array($result) ) {
echo("<P>" . $row["Name"] . "</P>"); }
?>
So i'm hanging up at // Select the Townhomes database ..
Any ideas?
---------------------------------------------