hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : it doesnt give an error and it doesnt work!
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

it doesnt give an error and it doesnt work!

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-13-2002, 04:31 AM
rami90_999 rami90_999 is offline
Newbie
 
Join Date: Sep 2002
Posts: 14
Unhappy

it doesnt give an error and it doesnt work!


Im doing a form that insert the values of the formfields entered into the database.. the page works just fine with no errors at all, however, it doesnt insert anything.. and im sure all the field properties are correct.. varchar for all of them and id for id with auto increment..

<?
while (list($name, $value) = each($HTTP_POST_VARS)) {

echo "$name = $value<br>\n";
} ;
if ($submit){

$db=mysql_connect ("localhost", "uname", "pword") or die ('I cannot connect to the database.');
mysql_select_db ("saydnaya_requestatour");

$tourname = $_POST["tourname"];
$numberofpeople = $_POST["numberofpeople"];
$language = $_POST["language"] ;
$transport = $_POST["transport"] ;
$date = $_POST["date"] ;
$budget = $_POST["budget"] ;
$hotel = $_POST["hotel"] ;
$nationality = $_POST["nationality"] ;
$email = $_POST["email"] ;
$name = $_POST["name"] ;


$sql = "INSERT INTO 'tourrequests' (tourname, numberofpeople, language, transport, date, budget, hotel, nationality, email, name) VALUES ('$tourname', '$numberofpeople', '$language', '$transport', '$date', '$budget', '$hotel', '$nationality', '$email', '$name')";


$result = mysql_query($sql);
echo "Thank you for request a tour, you will be emailed with the price quotation shortly" ;

} else {
?>

page comes then close the else..

http://12.129.206.122/~saydnaya/requesttour.php

try filling it in.. it will work and you will end up in the thank you page, with what u entered.. however, the data is not inserted to the db for some reason.. this is driving me mad, anyone has any ideas?

Thanks

Reply With Quote


Sponsored Links
  #2  
Old 09-13-2002, 04:40 AM
prosayist prosayist is offline
Junior Guru Wannabe
 
Join Date: Dec 2001
Location: New Hampshire
Posts: 93
I'm not deep into the *sql thing yet so maybe my suggestion isn't valid but whereby your values are variable, try removing the quotes
.. just an idea

__________________
WYSIWYG

Reply With Quote
  #3  
Old 09-13-2002, 04:45 AM
rami90_999 rami90_999 is offline
Newbie
 
Join Date: Sep 2002
Posts: 14
nope.. doesnt work.. thanks for ur suggestion anyway.. this bug is driving me nuts :-(

Reply With Quote
Sponsored Links
  #4  
Old 09-13-2002, 05:12 AM
Lats Lats is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Melbourne, AU
Posts: 740
I'd check for an error message, something like:

$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());


Lats...

Reply With Quote
  #5  
Old 09-13-2002, 06:03 AM
rami90_999 rami90_999 is offline
Newbie
 
Join Date: Sep 2002
Posts: 14
You have an error in your SQL syntax near 'than USD 500, **, TEST, TEST, TEST)' at line 1

argh.. i cant understand whats the problem.. anyways thanks lats.. but i dunno how to debug sql errors.. anyone knows how?

Reply With Quote
  #6  
Old 09-13-2002, 06:07 AM
Rich2k Rich2k is offline
Web Hosting Master
 
Join Date: May 2002
Location: UK
Posts: 2,994
You've got a problem with the insert of variables.

If the variable is a string is should be enclosed in single quotes, if it's a numeric value you don't need the quotes (but only if the field in the table is structured to only accept numeric values)

Reply With Quote
  #7  
Old 09-13-2002, 06:19 AM
rami90_999 rami90_999 is offline
Newbie
 
Join Date: Sep 2002
Posts: 14
do you mean in the query or in defining the vars?

Besides, what should the fields be set to accept numeric and non numeric data?

Reply With Quote
  #8  
Old 09-13-2002, 06:52 AM
Rich2k Rich2k is offline
Web Hosting Master
 
Join Date: May 2002
Location: UK
Posts: 2,994
I can't answer that... it depends on how you configured your database.

Reply With Quote
  #9  
Old 09-13-2002, 11:59 AM
rami90_999 rami90_999 is offline
Newbie
 
Join Date: Sep 2002
Posts: 14
thanks anyways rich2k.. i guess this will never work with me.. i better try the other way.. mail() function to directly email me the ofrm results but the problem there.. i dont know how to put all the variables into one variable.. and arrays are not allowed in mail() function

Reply With Quote
  #10  
Old 09-13-2002, 12:43 PM
Alturus Alturus is offline
Newbie
 
Join Date: Aug 2002
Location: Canada
Posts: 22
As Rich2k said, check your conditions on your SQL fields.

for example:

varchar(2) won't accept 'Jimmy Jones and the Funky Bunch'

int(5) won't accept 'lick'

Reply With Quote
  #11  
Old 09-13-2002, 12:44 PM
ranchoweb ranchoweb is offline
Junior Guru Wannabe
 
Join Date: Mar 2002
Location: San Jose, CA
Posts: 34
looks like one of your variables to be inserted has a single quote in it. Check each variable for single quotes and replace it with \' ... like so:


$var = ereg_replace("'","\'",$var);

__________________
ranchoweb.com
reliable linux hosting with all the trimmings
http://www.ranchoweb.com/webhost/

Reply With Quote
  #12  
Old 09-13-2002, 03:29 PM
nookie nookie is offline
New Member
 
Join Date: Sep 2002
Posts: 1
or

mysql_escape_string($var);


Reply With Quote
  #13  
Old 09-13-2002, 04:26 PM
apokalyptik apokalyptik is offline
Newbie
 
Join Date: Aug 2002
Posts: 19
check your...

magic quotes settings in the php.ini

also your register globals settings

__________________
irc.apokalyptik.com http://www.apokalyptik.com http://www.apokalyptik.com/forum/

Reply With Quote
  #14  
Old 09-14-2002, 09:44 AM
rami90_999 rami90_999 is offline
Newbie
 
Join Date: Sep 2002
Posts: 14
Cannot query the database.
Column count doesn't match value count at row 1

Latest error.. i removed most fields and still got the error so i put at the end of the query $lastvariable, ')" see that comma and single quote? thats what removed the errrors lol, now i have that error.. and ive no idae what it means.. i dont have much experience in SQL

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
If AWS Rakes in $2.4B Per Year, What Does it Mean for its Competitors? Blog 2013-04-26 15:53:59
Rackspace Adds Redis as a Service with Exceptional Cloud Services Acquisition Web Hosting News 2013-04-01 10:55:48
Expired SSL Certificate Brings Down Windows Azure Cloud Web Hosting News 2013-02-25 10:38:00
Web Host 1&1 Experiences Server Outage Web Hosting News 2011-09-26 17:29:11
Web Host Dotpulse Launches New Affiliate Program Web Hosting News 2011-07-14 20:53:20


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?