Forum Moderators: coopster
$query = "INSERT INTO user (host, Name, Email, Comments, select_priv, insert_priv, update_ priv) VALUES ('http://www.example.com', '$name', '$email', '$message', 'Y', 'Y', 'Y')";
mysql_query($query) or die('Error, insert query failed');
As it comes up with "Error, insert query failed" on the page. So, the script is 'working', as i've eliminated all the parse errors and such, but i'm not sure why this isn't working.
name, email and comments are the only things on the form to submit. And i'm doing this on my website, not locally. So have i got everything right? This is the first time i've attempted a thing like this...
thanks
:)
<?php
include 'database/config.php';
include 'database/opendb.php';
// collect data from table
$data = mysql_query ("SELECT * FROM guestbook")
or die (mysql_error());
$info = mysql_fetch_array ( $data );
while ($info = mysql_fetch_array( $data ))
{
echo "<p>Name: " .$info['Name'] . "</p>";
echo "<p>Comment: " .$info['Comments'] . "<br />-------------------------------</p>";
}
?>
:)
normally you would use ORDER BY in your select query to get them in some kind of order but you don't have anything to order them by as of yet ;)
date or id would work
However i cant get order by to work. I've searched for various tutorials around the net on order by, but none seem to work for me.
When i'm not getting parse errors and the like, i get this -
Unknown column 'date' in 'order clause'
From this line
$data = mysql_query ("SELECT DATE(CURRENT_TIMESTAMP) FROM guestbook ORDER BY date")
Why is this wrong? Do i need to set the date and time first?
Different tutorials write different things on how to order the results. Or do i need to set the date when writing the form data to the database and then order the results using
SELECT * FROM guestbook ORDER BY date
:)
normally you would use ORDER BY in your select query to get them in some kind of order but you don't have anything to order them by as of yet
you did mention adding a date column, though even a unique auto incremented id would work (both of which you would need to add to the table)
as it stands you have name, email and comment. None of these give you anything much to order by except alphabetical.