MYSQL Connection Woes

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
centipede
Forum Newbie
Posts: 7
Joined: Thu Sep 04, 2003 9:45 pm

MYSQL Connection Woes

Post by centipede »

below is a test document i have created. i have been building a site locally for a few weeks now, and just bought space on 1t3, my url is http://entwork.com. everything works fine locally, but on the 1t3 server i can't seem to access my database. it may be a problem with the database itself, but i was wondering if anyone sees something within my code that might be the culprit. i know the user name is correct, there is no password, and the table does exist, and has data in it. here is the test document:


Code: Select all

<html>
<head>
	<title>test</title>
</head>

<body>
	begin to call the db:
	
	<br />
	
	<?php
		//connect to the server
		$link = mysql_connect("localhost", "cent", "")
		    or die("Could not connect");
		
		//select the database
		mysql_select_db("dbtree") or die("Could not select database");
		
		//run the query
		$sQuery = "select * from tbltree";
		$result = mysql_query($sQuery,$link) or die("Query failed");
		
		echo extract(mysql_fetch_assoc($result));
		
		while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) &#123;
			echo $line&#1111;"Caption"];
		&#125;
	?>
</body>
</html>

thanks!!!
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

What do you get if you substitute this in your code:

Code: Select all

<?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
{         
    echo '<pre>';    
    print_r($line);
    echo '</pre>';    
} 
?>
Post Reply