[thelist] mySQL and PHP troubles

Anthony Baratta Anthony at Baratta.com
Mon Sep 3 00:34:52 CDT 2001


At 09:04 PM 9/2/2001, you wrote:
>At 11:47 pm 9/2/01, you wrote:
> >Better yet can you post all the relevant code including your 
> includes/functions?
>
>I have been able to connect to the DB with this function from the include 
>db_connect(). I created the DB 'sample_db' and the table 'user', 
>populating it through PHP.
>
>Here is the code: (from the file show_db.php)

I don't see a place where you are changing the target Database to "sample_db".

Your function "db_connect()" just ignores and variables passed to it, so my 
guess is that you are attempting to select against a nonexistent table 
within the test database.

Try changing,

$default_dbname = 'sample_db';

If you want to change the target DB after your connect you can try:

$link_id = db_connect();
mysql_select_db ('sample_db',$link_id);
$result = mysql_query("select * from user", $link_id);

Take a look at the examples here:
http://www.php.net/manual/en/function.mysql-connect.php
http://www.php.net/manual/en/function.mysql-select-db.php
http://www.php.net/manual/en/function.mysql-fetch-row.php
---
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."





More information about the thelist mailing list