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
Once again....PHP is driving me nuts.
Old 08-18-2004, 12:28 PM Once again....PHP is driving me nuts.
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
So......another problem.

I have a form that when submitted adds the data to a database. I have at least 2 other forms like this within my site and they work perfectly . However this one doesn't, the code is, as far as i can see, exactly the same as the other forms (with the table data etc changed). The error i get is:

Couldn't add data to "reviews" table: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'show, body, rating) values('Stoot', 'Hello', 'Hellooo', '7'


The code i'm using is:

PHP Code:
include("config.php");


$name_submit $_POST['name'];
$show_submit $_POST['show'];
$body_submit $_POST['body'];
$rating_submit $_POST['rating'];
    
if (
$name_submit == "" OR $show_submit == "" OR $body_submit == "" OR $rating_submit == "") {
    
print 
"You must enter something in each field!";
print 
"<br>";
print 
"<br>";
print 
"<a href = \"javascript:history.back(-1)\">Return and correct...</a>";


} else {


$query "INSERT INTO reviews ( name, show, body, rating)
            values('
$name_submit', '$show_submit', '$body_submit', '$rating_submit')";
            
mysql_query($query)
or die (
"Couldn't add data to \"reviews\" table: "
.mysql_error() );


print 
"Your review has been submitted.  Thanks!";
print 
"<br>";
print 
"<br>";
print 
"<a href = \"gigs.php?skin=$skin\">Back to Gigs listings</a><br><br>";


I really can't figure it out, so any help would be great.
Sorry for keeping asking questions. Cheers

Stoot
stoot98 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-18-2004, 12:44 PM
KeithMcL's Avatar
Super Talker

Posts: 128
Location: Dublin, Ireland
Trades: 0
It sounds like it's not finding the right columns in the reviews table or else the reviews table itself doesn't exist. Did you double check them?

The only other thing I suggest is to try removing the blank space before the word name in
PHP Code:
$query "INSERT INTO reviews ( name, show, body, rating) values('$name_submit', '$show_submit', '$body_submit', '$rating_submit')"
__________________

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
KeithMcL is offline
Reply With Quote
View Public Profile
 
Old 08-18-2004, 01:07 PM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
Trades: 0
How are you connected? You sure you don't need a DB pointer as an arguament to your query? whats in your config.php, and whats the tables setup?
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources,
Please login or register to view this content. Registration is FREE
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Old 08-18-2004, 01:34 PM
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
Config.php:

PHP Code:
<?php

$link 
mysql_connect("localhost""XXX""XXXXX");
if (! 
$link)
    die(
"Couldn't connect to MySQL");
    
mysql_select_db("afi") or die ("Couldn't open database");


?>
The table structure is:

Reviews
id
name
show
body
rating

I've recreated the table and checked it so many times. The config.php setup HAS to be fine else the rest of the site wouldn't work, but it does.

If you want to check it out properly, the url is www.tearsofjoy.co.uk go to 'Gigs' then 'Submit Review'

Ugh this is really annoying me.
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 08-18-2004, 03:25 PM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
Trades: 0
show is a reserved word (it can't be a field name). Also, you may want try replacing mysql_query($query) with mysql_query($query,$link).
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources,
Please login or register to view this content. Registration is FREE
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Old 08-19-2004, 03:20 PM
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
You're the man WebwoRRks!!!! That's what did it. I changed 'show' to 'gig' and it worked fine. Thanks everyone for their help. woo
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 08-19-2004, 03:49 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
You can still use 'show' as a field name, you just have to surround it by backticks,
INSERT INTO table SET `show`='data'
But I'm like you, I'd rather rename it then have those ugly backticks everywhere ><
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
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

Christopher is offline
Reply With Quote
View Public Profile
 
Old 08-20-2004, 07:05 AM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
Trades: 0
plus its just plain naughty chroder
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources,
Please login or register to view this content. Registration is FREE
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Reply     « Reply to Once again....PHP is driving me nuts.
 

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