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’
Name | Date Registered |
' . $row['name'] . ' | ' . $row['dr'] . ' |
The curent users could not be retrieved. We apologize for any inconvenience.
'; //Debugging message: echo '' . mysqli_error($dbc) . '
Query: ' . $q . '
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