The mysql_select_db() function is going to return a handle.  You need to
capture that handle and use it as the second parameter in your mysql_query()
function.  Although this is not required in certain cases where the server
automatically knows which database to work with, chances are thats whats
giving you the error.

Use like this..
$db = mysql_select_db();
mysql_query($query, $db);

-Kevin

----- Original Message -----
From: "Randum Ian" <[EMAIL PROTECTED]>
To: "PHP" <[EMAIL PROTECTED]>
Sent: Friday, May 17, 2002 11:45 AM
Subject: [PHP] mysql error


> Hi all,
>
> I have got this code but I can get it to work, it doesnt make sense!
>
> <snip>
> <?php
>
>  $host="localhost";
>  $username="user";
>  $password="pass";
>  $database="admin";
>
>  $mysqlconnect = mysql_connect($host, $username, $password) or die
("Cannot
> connect to mySQL server, check it is running");
>
>  mysql_select_db($database, $mysqlconnect) or die ("Cannot connect to the
> database, check it is set right");
>
>  $result = mysql_query("SELECT * FROM user");
>
>  $count = mysql_num_rows($result);
>
>  $counted = number_format($count);
>
>  echo $counted;
>
>  ?>
> <snip>
>
> but I am getting this error - "Warning: Supplied argument is not a valid
> MySQL result resource in /usr/home/e/a/eagadmin/public_html/main.php on
line
> 14" but I dont understand why!
>
> Can anyone help?
>
> Regards, Ian.
> ---
> Randum Ian
> DJ / Reviewer / Webmaster, DancePortal (UK) Limited
> [EMAIL PROTECTED]
> http://www.danceportal.co.uk
> DancePortal.co.uk - Global dance music media
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to