Thanks for the reply's, I am still not to clear as what is wrong with my origianl syntax.
I could use these different ideas, but I am really trying to debug the original script I sent. I got the example from Beginning PHP book by wrox. ta. "Koelwebdesign" <[EMAIL PROTECTED]> wrote in message 000b01c1785b$8a1b8160$d4f5f1c3@koelwebdesign">news:000b01c1785b$8a1b8160$d4f5f1c3@koelwebdesign... > which is even better, all I tried to do was to point out just how simple it > can be... > btw. I prefer mysql_fetch_array > > ps. > (ik woon in koudekerk, kilometertje of 8 van waddinxveen en werk als > tekenaar op een ingenieursburo... klein wereldje) > > Leo Kuiper > > "Building a map in order to find what's not lost but left behind." > - Beth Orton > > > ----- Original Message ----- > From: Roel Mulder <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, November 28, 2001 11:15 PM > Subject: Re: [PHP-DB] db connect problems. > > > > Or what about: > > > > common_db.inc with just the following: > > (which you would for security reasons put in a directory outside the > > webroot, and rename the file to .common_db.inc (with a . in front of it)) > > <?php > > $dbhost = 'localhost'; > > $dbusername = 'root'; > > $dbuserpassword = ''; > > $default_dbname = 'mysql'; > > ?> > > > > show_more_db.php with > > <?php > > include "./common_db.inc"; > > mysql_connect($dbhost, $dbusername, $dbuserpassword) > > or die ("<b>Couldn't connect to specified server</b>"); > > mysql_select_db($default_dbname) > > or die ("<b>Error, no database found sweetheart</b>"); > > > > $sql = "SELECT * FROM user"; > > $result = mysql_query($sql); > > while ($row = mysql_fetch_row($result)) { > > echo ($row[1]."<br>\n"); > > } > > > > mysql_close(); > > ?> > > > > Groetend, > > Roel Mulder > > > > At 22:52 28-11-2001 +0100, you wrote: > > >well, I didn't debug this massive script, but > > >maybe you just want to connect to a mysql database? > > >then this is the short way: > > > > > >$user = "your_username_for_the_database"; > > >$pass = "your_password_for_the_database"; > > > > > >$con = mysql_connect("your_host", $user, $pass); > > > > > >if(!$con) { > > > print "no connection"; > > >} > > > > > >I really don't know if this is what you're asking for.... > > > > > >Leo Kuiper > > > > > >"Building a map in order to find what's not lost but left behind." > > > - Beth Orton > > > > > > > > >----- Original Message ----- > > >From: Ian <[EMAIL PROTECTED]> > > >To: <[EMAIL PROTECTED]> > > >Sent: Wednesday, November 28, 2001 5:52 PM > > >Subject: [PHP-DB] db connect problems. > > > > > > > > > > Hello, wonder if anyone can debug this script. > > > > > > > > I copied it from an example in a book. > > > > > > > > There is a .php file and a .inc file > > > > > > > > This is the .inc file: > > > > > > > > <?php > > > > file://common_db.inc > > > > $dbhost = 'localhost'; > > > > $dbusername = 'root'; > > > > $dbuserpassword = ''; > > > > $default_dbname = 'mysql'; > > > > $MYSQL_ERRNO = ''; > > > > $MYSQL_ERROR = ''; > > > > function db_connect($dbname="") { > > > > global $dbhost, $dbusername, $dbuserpassword, $default_dbname, > $dbname; > > > > global $MYSQL_ERRNO, $MYSQL_ERROR; > > > > $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword); > > > > if(!$link_id) { > > > > $MYSQL_ERRNO = 0; > > > > $MYSQL_ERROR = "Connection failed to the host $dbhost."; > > > > return 0; > > > > } > > > > else if(empty($dbname) && !mysql_select_db($default_dbname)) { > > > > $MYSQL_ERRNO = mysql_errno(); > > > > $MYSQL_ERROR = mysql_error(); > > > > return 0; > > > > } > > > > else return $link_id; > > > > } > > > > function sql_error() { > > > > global $MYSQL_ERRNO, $MYSQL_ERROR; > > > > if(empty($MYSQL_ERROR)) { > > > > $MYSQL_ERRNO = mysql_errno(); > > > > $MYSQL_ERROR = mysql_error(); > > > > } > > > > return "$MYSQL_ERRNO: $MYSQL_ERROR"; > > > > } > > > > ?> > > > > > > > > > > > > the .php file is like this: > > > > > > > > <?php > > > > file://show_more_db.php > > > > include "./common_db.inc"; > > > > $link_id = db_connect('sample_db'); > > > > $result = mysql_query("SELECT * FROM user", $link_id); > > > > while($query_data = mysql_fetch_row($result)) { > > > > ?> > > > > <?php > > > > echo "'",$query_data[1],"' is also php ' known as > ",$query_data[3],"<P>"; > > > > } > > > > ?> > > > > > > > > Sorry about poxy formatting, hope it is legible. > > > > > > > > I seem to have a problem passing the database to the db_connect() > function > > > > within the .php script. > > > > The $default_dbname variable within the .inc file is always selected > > >instead > > > > of the argument I pass. > > > > > > > > Anyone help me please? > > > > > > > > Ta. > > > > > > > > Mulder Technisch Advies > > Postbus 69 > > NL-2740 AB WADDINXVEEN > > tel. 0182-640184 fax. 0182-640185 > > http://www.mta.nl > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]