TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 02-26-2008, 11:52 PM   #1 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 87
Thanks: 49
StevenF is on a distinguished road
Default 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) == ) {
        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
__________________
My Personal and Photo Blog
StevenF is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:35 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design