Page 1 of 1

This should work but i get an error... ( mysql_query )

Posted: Tue Sep 22, 2009 4:31 pm
by gimmikk
Does anyone can help me to sort out this problem?
here is my php code

Code: Select all

 
    
    $page_title='View the Current Users';
    include('includes/header.html');
    
    //Page header
    echo '<h1>Registered Users</h1>';
    
    //connect to DB
    require_once('mysql_connect.php');
    $dbc = mysql_connect('localhost','root','root','sitename');
    
    //make Query
    $q = "SELECT CONCAT(last_name, ', ',first_name) AS name,
    DATE_FORMAT(registration_date, '%M %d,%Y') AS dr FROM users ORDER BY registration_date ASC";
    
    $result = mysql_query($dbc, $q);
    
 
and this is the error i get.
----------------------------------------------------------------------------------

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/test2/view_users.php on line 17

-----------------------------------------------------------------------------------

I've also tried

"$result = @mysqli_query($dbc, $q)"

but either of them don't work.

Mac OS x
MySQL 5.0.41
PHP 4.4.8 & 5.2.6

Re: This should work but i get an error... ( mysql_query )

Posted: Tue Sep 22, 2009 4:39 pm
by requinix

Code: Select all

$result = mysql_query($dbc, $q) or die(mysql_error($dbc));
and see what MySQL is complaining about.