Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-06-2005, 12:51 PM N00b problem
Hawkallica's Avatar
Novice Talker

Posts: 7
Trades: 0
PHP Code:
<?php
    
include "logindb.php";
    
    
$sql_table "demo";
     
    
$sql "INSERT into demo (fname, lname, email, sadrs, city, state, zip, phone, demo) VALUES('$fname', '$lname', '$email', '$sadrs', '$city', '$state', $zip', '$phone', '$demo')";
?>
I am real n00b when it comes to inserting info into the database. That code doesn't seem to put anything in the database. I have a table called demo, and everything in logindb.php is correct. I have all the fields in the databse correct, so I would guess that something is wrong with the code.
Hawkallica is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-06-2005, 12:55 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Are you executing the query anywhere? All I see above is an include and two variables. Nothing that would execute the mysql query. In other words, are you using this function anywhere...

PHP Code:
mysql_query($sql
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 03-06-2005, 01:02 PM
Hawkallica's Avatar
Novice Talker

Posts: 7
Trades: 0
nope, I added it though, I dont if I did it correctly, but it doesn't seem to give me an error, but it still doesn't insert the info to the database:

PHP Code:
<?php
    
include "logindb.php";
    
    
$sql_table "demo";
     
    
mysql_query($sql) == "INSERT into demo ('', 'fname', 'lname', 'email', 'sadrs', 'city', 'state', 'zip', 'phone', 'demo') VALUES('', '$fname', '$lname', '$email', '$sadrs', '$city', '$state', $zip', '$phone', '$demo')";
?>
my fields within my table demo in order is:
id int(11)
fname vachar(30)
lname vachar(30)
email vachar(50)
sadrs vachar(50)
city vachar(15)
state vachar(15)
zip int(5)
phone int(10)
demo vachar(30)

Last edited by Hawkallica; 03-06-2005 at 01:07 PM..
Hawkallica is offline
Reply With Quote
View Public Profile
 
Old 03-06-2005, 03:26 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
mysql_query() is a function call, and you need to get your query string in between the brackets - this is passing a parameter to the function.

In your first attempt, you never called the function, in the second try, you have changed things around so that $sql is never set. You need to rewrite it as you had in the first example, and just add the line that cptnwinky gave you:

PHP Code:
<?php
    
include "logindb.php";
    
    
$sql_table "demo";
    
    
//This sets your variable
    
$sql "INSERT into demo (fname, lname, email, sadrs, city, state, zip, phone, demo) VALUES('$fname', '$lname', '$email', '$sadrs', '$city', '$state', $zip', '$phone', '$demo')";

    
//This calls the function, using the variable we set above
    
mysql_query($sql);
?>
Make sense?
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to N00b problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.47568 seconds with 12 queries