02-26-2008, 11:52 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Posts: 87
Thanks: 49
|
Basic If Statement Help
Hi guys,
I have what I think is a very basic question: I have a form which inserts data into a database. When the form is submitted (when mysql_query($query) = true) I want to echo "A new row has been added".
Here's the code:
PHP Code:
//Creating a query that enters the data into a database
$query = 'INSERT INTO products SET cd_artist = "'.mysql_real_escape_string($cd_artist).'",
cd_title = "'.mysql_real_escape_string($cd_title).'",
cd_price = "'.mysql_real_escape_string($cd_price).'",
cd_image_name = "'.mysql_real_escape_string($cd_image_name).'"';
//execcute a query on a MySQL database
mysql_query($query);
//Message
if (mysql_query($query) == 1 ) {
echo ("A new row has been added to the database");
}
I also tried:
PHP Code:
//Message
if (mysql_query($query)) {
echo ("A new row has been added to the database");
}
No luck. I know this is something very basic, but I can't get it to work
Thanks,
Steven
|
|
|
|