Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 05-14-2004, 01:36 PM   #1 (permalink)
bearslife
Registered User
 
Join Date: May 2004
Location: Kellogg, Idaho
Posts: 2
bearslife is on a distinguished road
Exclamation Trouble inserting multiple records into table, Please someone help me! Thanks

Hi all how are you? I am just having a bit of an issue with my form script and mysql, inserting records from this form of mine into my table in my database.
it looks like all my others and they work, so what could be so wrong with this. Here
let me show you the code


CODE

PHP Code:
<?php
$host
="xxxxxxxxx";
$username="xxxxxxx";
$password="xxxxxx";
$db="xxxxx";
$link=mysql_connect($host,$username,$password);
if (!
$link)
die(
"Couldn't connect to MySQL");
mysql_select_db($db,$link)
or die(
"couldn't open $db:".mysql_error());


$sender_firstandlast =$_POST['sender_firstandlast'];
$sender_companyname =$_POST['sender_companyname'];
$sender_email=$_POST['sender_email'];
$sender_phonenumber=$_POST['sender_phonenumber'];
$how_recieve=$_POST['how_recieve'];
$websitetitle=$_POST['websitetitle'];
$what=$_POST['what'];
$websitedetails=$_POST['websitedetails'];
$websitebudget=$_POST['websitebudget'];
$how_pages=$_POST['how_pages'];
$completiondate=$_POST['completiondate'];
$currenturl=$_POST['currenturl'];
$chooseany=$_POST['chooseany'];
$size=$_POST['size'];
$scripts=$_POST['scripts'];
$databases=$_POST['databases'];
$scriptdetails=$_POST['scriptdetails'];



mysql_select_db($db) or die("Cannot select the database.<br>" mysql_error());
$result=mysql_query("INSERT INTO quote (sender_firstandlast, sender_companyname, sender_email, sender_phonenumber, how_recieve, websitetitle, what, websitedetails, websitebudget, how_pages, completiondate, currenturl, chooseany, size, scripts, databases, scriptdetails) VALUES ('$sender_firstandlast','$sender_companyname','$se nder_email','$sender_phonenumber','$how_recieve',' $websitetitle','$what','$websitedetails','$website budget','$how_pages','$completiondate','$currentur l','$chooseany','$size','$scripts','$databases','$ scriptdetails')")or die("Insert Error: ".mysql_error());


?>
<?php
include("steveform.php");
?>
All my other scripts use this for their inserting data and so why doesn't this work. The variables are all set right im sure. They carry the same name= as in the form names. the names are correct in the Database Table. May be I entered the data the wrong way in my database??? I don't know, I've tried everything and my form is not running, well dumby me i need to put up my backup, duh, but in the mean time i would really like to solve this, please help me anyone. thanks

Last edited by sde; 05-14-2004 at 03:25 PM.
bearslife is offline   Reply With Quote
Old 05-14-2004, 02:48 PM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
and your error message is...?
what does php print out? what is in the mysql log? also do yourself a favor and print out the sql statement that you're passing to mysql_query(), so that you (and us) can look at what is actually being given to the database.
joe_bruin is offline   Reply With Quote
Old 05-14-2004, 03:30 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
yes, as joe said, please post the errors .. if you are not getting errors for some reason, try troubleshooting the sql query itself. below, i make a string called $sql and echo it to the screen.

an easy way to test to see if this is a good sql query or not is paste the output into phpmyadmin and see if it reports any errors.

PHP Code:
$sql "INSERT INTO quote (sender_firstandlast, sender_companyname, sender_email, sender_phonenumber, how_recieve, websitetitle, what, websitedetails, websitebudget, how_pages, completiondate, currenturl, chooseany, size, scripts, databases, scriptdetails) VALUES  ('$sender_firstandlast','$sender_companyname','$se
  nder_email','$sender_phonenumber','$how_recieve','
  $websitetitle','$what','$websitedetails','$website
  budget','$how_pages','$completiondate','$currentur
  l','$chooseany','$size','$scripts','$databases','$
scriptdetails')"
;

echo 
$sql
__________________
Mike
sde is offline   Reply With Quote
Old 05-14-2004, 05:59 PM   #4 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
This has already been answered on another forum site. 'databases' is a MySQL reserved word. Is there something you don't understand about that?
bdl is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Would be really grateful for help with inserting multiple records debbieau PHP 2 06-16-2004 04:06 PM
Scanning for multiple entries in a table jimmyoctane PHP 2 11-15-2003 08:19 PM
help me name a table sde Lounge 4 12-07-2002 12:50 PM


All times are GMT -8. The time now is 01:21 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting