How to format mySQL data into an html table

I read that page, but can’t figure out what the heck is going on, it gave me this error.

“Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host ‘DB_SERVER’ (11001) in C:Custom Programswampwwwphp_sandboxdbconnection.php on line 4
Sorry gangsta, the database connection failed: Unknown MySQL server host ‘DB_SERVER’ (11001)”

but dbconnection.php works in my other pages. anyways, in the code from that article, what do i change?

my database name is widget_corp and it connects through dbconnection.php, and in dbconstants.php are my username and password to connect to the database etc.

I have a table named subjects. Inside the table subjects i have 4 rows named ID MENU_NAME POSITION and VISIBLE

what do I replace with what in that articles code?

here’s the article code: [code]<?php

// load configuration


// connect to db


$sql = "SELECT item_name FROM items;";

		$result = mysql_db_query($db_name,$sql);


if (!$result || mysql_num_rows($result) < 1) {

			print mysql_error() . ' ERROR - SELECT note query failed! ';


// get result into array



for ($i=0; $i<$rows; $i++) {




// break array over rows

print ‘


while($i <= count($arr)) {

// row of five items

print '<tr>';

	for($r=1;$r<=5;$r++) {

	print '<td>'. $arr[$i] .'</td>';



print '</tr>';


print ‘



i’m just guessing:

the other script has a line like:
define(“DB_SERVER”, “localhost”);

this line is missing now.
a undefined constant defaults to containing the string of its name.
so leafing that line away is the same as using:
define(“DB_SERVER”, “DB_SERVER”);

now mysql_connect trys to find a sever called DB_SERVER.
that is not a vaild server name like “localhost”, “” or “” would have been.

that makes mysql_connect fail.

plz look for a define(“DB_SERVER”,… in the working script.
if u find it copy that line to ur new script.

Sponsor our Newsletter | Privacy Policy | Terms of Service