Unknown column 'first_name' in 'field list', Two scripts give me same error!

Hi all, I am newbee. I am working on two of my first scripts that use PHP and Sql together. Both scripts give me the same error! Unknown column ‘first_name’ in ‘field list’. I think the problem is something in the line of script : require (‘mysqli_connect.php’); ? but I could be all wrong.
____________________________________________________________________________________________The required connect script for the following script with the error message is here: I just xed out the password stuff… but the script works and does connect to the database. Because both scripts that are dependent upon this script I assume something about my syntax of calling this script is wrong.
[php] <?php # Script 9.2 mysqli-connect.php

//This file contains the database access informatin.
//This file aslo establishes the a connection to MySQL,
//selects the database, and sets the encoding.

//Set the database access information as constants:
DEFINE (‘DB_USER’, ‘xxxxxx’);
DEFINE (‘DB_PASSWORD’, ‘’);
DEFINE (‘DB_HOST’, ‘localhost’);
DEFINE (‘DB_NAME’, ‘acquia_drupal’);

//Make the connection:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect the MySQL: ’ . mysqli_connect_error() );
mysqli_set_charset($dbc,‘utf8’);
[/php]


[php] <?php # Script 9.4 -view_users.php

$page_title = ‘View the Current Users’;
include (‘includes/header.html’);
echo ’

Registered Users

’;
require (‘mysqli_connect.php’);
$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”;
$r = @mysqli_query($dbc,$q);
if ($r) {
echo’'; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '';} echo '
Name Date Registered
' . $row['name'] . ' ' . $row['dr'] . '
'; mysqli_free_result ($r); } else{//If it did not run okay //public message echo '

The curent users could not be retrieved. We apologize for any inconvenience.

'; //Debugging message: echo '

' . mysqli_error($dbc) . '

Query: ' . $q . '

'; } //End of if($r) mysqli_close($dbc); //Close the database connection.

include (‘includes/footer.html’);
?>

[/php]
Any ideas appreciated. I am a newbee and I thought I was getting it and than I found out … I am not.
Thank you in advance learned persons!
Jaloney

Do you have a column named first_name in your database ?
It looks like you are trying to use it in the SELECT CONCAT but does it actually exist ?

$q = "SELECT CONCAT(last_name, ', ', first_name) AS

Tascam424
WOW that is a good suggestion. Newbee I am.
I will check that out.
THANKYOU !!!
Jaloney

Thank you Tascam424,
apparently the textbook scripts do not exactly match the database provided by the school to run the scripts. I learned something though, which is the point.
THANK YOU!
Jaloney

Hey i’m still learning too … it’s just nice to be able to give something back !!

How do I send you good Karma points???

Thats very kind !! … I think you just hit the little + symbol below my name to the left of a post !

Sponsor our Newsletter | Privacy Policy | Terms of Service