Don't mix mysql_ functions with mysqli_ functions, and you'll have much
greater successes.

$dbcon = mysql_connect( 'localhost', 'root', 'password', 'database_name'
        should be
$dbcon = mysqli_connect( 'localhost', 'root', 'password',
'database_name' ); 

- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257

The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.

-----Original Message-----
From: Richard Hart [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 30, 2005 12:06 PM
To: Bastien Koert;
Subject: RE: [PHP-DB] Help with. .

Thanks for your help Bastien.

I have changed the authentication procedure but have come up against
This time I am allowing the users to choose their unique usernames and
passwords which
will be stored in a mysql database. However when I check to see if their
details exist
in the databse I get:

Warning: mysqli_query() expects parameter 1 to be mysqli, resource given

any help would be appreciated.

Here is the code:


// connect to mysql
$dbcon = mysql_connect( 'localhost', 'root', 'password', 'database_name'
if (!$dbcon) {
        echo 'Cannot connect to the database.';

// query the database to see if there is a matching username and
$query = "select count(*) from users where username = '$username' and
password = '$password'";

$result = mysqli_query($dbcon, $query);
if (!$result) {
        echo 'Sorry can't run query';
$row = mysqli_fetch_row($result);
$count = $row[0];

if ($count > 0) {
        echo 'You have successfully logged on.';
else {
        echo "Your username and/or password have not been accepted.
Please <a
href='javascript:history.back();'>go back</a> and try again.";



-----Original Message-----
From: Bastien Koert [mailto:[EMAIL PROTECTED]
Sent: 30 August 2005 00:59
Subject: RE: [PHP-DB] Help with

you don't have a connection to the db...either because the
name.password, db
name are wrong or you lack the needed permissions to allow the query...

note that this query is a really back idea...opens the whole db
to provide one connection and allow the users basic read write access


>From: "Richard Hart" <[EMAIL PROTECTED]>
>To: <>
>Subject: [PHP-DB] Help with Date: Mon, 29 Aug 2005 23:27:46 +0100
>I'm new to PHP/MySQL and wondered if anyone on this list would be kind
>enough to help me solve
>this problem. I'm trying to automatically set up a users privileges on
>MySQL table using the
>username and password selected by them in an html form. I get the error
>"Warning: mysql_query(): supplied argument is not a valid MySQL-Link
>for the code below:
>@ $db = new mysqli('localhost', 'root', 'password', 'database_table');
>if (mysqli_connect_errno())
>       echo 'Error: Could not connect to database. Please try again
>       exit;
>$grant_privilege = "grant select, insert, delete, update on
>$username identified by '$password'";
>mysql_query($grant_privilege, $db);
>Can anyone help?
>PHP Database Mailing List (
>To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to