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
Please help with INSERT query
Old 09-07-2007, 11:22 AM Please help with INSERT query
scrobins's Avatar
Skilled Talker

Posts: 50
Name: Stuart Robinson
Location: Busselton
Trades: 0
After battling this for more than a couple hours I can't see straight anymore. Can anyone please point out the friggin' obvious mistake I'm making?

PHP Code:
$user$_SESSION['userid'];
$feedstripslashes($_GET['fd']);

    
$nw_query "INSERT INTO picks VALUES ('','$feed','$user','')";
    
$nw_resultmysql_query($nw_query);
        
if ( ! 
$nw_query ) {
    
mysql_error();

The table that I'm trying to enter these values into is;

pickID int(6) auto increment
pickFeed varchar(200) null
userID int(6) null
pickDate datetime null

Cheers.
scrobins is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-07-2007, 11:32 AM Re: Please help with INSERT query
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
If you have a default value on a field, don't try to override it with an empty value, especially on your primary key...
Code:
INSERT INTO picks (pickFeed, userId) VALUES ('$feed','$user');
I wonder why you put default values to null, and try to assign them an empty value ?
Take care, '' != null.
null means no value, '' means an empty value, which is not null.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-07-2007, 01:38 PM Re: Please help with INSERT query
Ultra Talker

Posts: 483
Trades: 0
I would assume, also, that if you changed:
if ( ! $nw_query ) {
mysql_error();
}

to:
if ( ! $nw_result ) {
echo mysql_error();
}

then you might get that error message to show.
__________________

Please login or register to view this content. Registration is FREE
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 08:37 PM Re: Please help with INSERT query
scrobins's Avatar
Skilled Talker

Posts: 50
Name: Stuart Robinson
Location: Busselton
Trades: 0
Cheers guys. I've made the changes but still no joy. Plus, the error message isn't being produced.

Any more ideas?
scrobins is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 09:11 PM Re: Please help with INSERT query
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
Can you give more code including more php, a desc table on the tables or a run down of the db structure?
joder is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 11:01 PM Re: Please help with INSERT query
scrobins's Avatar
Skilled Talker

Posts: 50
Name: Stuart Robinson
Location: Busselton
Trades: 0
Hey guys. Thanx for the help. I've fixed it by doing changing this;

PHP Code:
INSERT INTO picks (pickFeeduserIdVALUES ('$feed','$user'); 
to this
PHP Code:
INSERT INTO picks (pickFeeduserIdVALUES ($feed,'$user'); 
by dropping the '' on the $feed variable. It was producing the $feed variable with double single quotes.
scrobins is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 11:19 PM Re: Please help with INSERT query
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
I'll have to admit, I don't understand how that could have worked.
http://www.phpfreaks.com/mysqlref/2.php
joder is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 11:38 PM Re: Please help with INSERT query
scrobins's Avatar
Skilled Talker

Posts: 50
Name: Stuart Robinson
Location: Busselton
Trades: 0
Cool. I thought it was just me.

For another problem, that's not completely unrelated, how can i remove the single quotes from the start and end of a string variable? I've been playing around with str_replace, preg_replace and substr_replace but each of them require a replacement string.

All I want to do is remove them completely as in this string;

'http://feeds.feedburner.com/~r/GardeningTipsnIdeas/~3/153206427/7_garden_horror_stories.html'
scrobins is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Please help with INSERT query
 

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.70133 seconds with 12 queries