MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 24th, 2005, 11:44 AM
fezbro fezbro is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 4 fezbro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 44 sec
Reputation Power: 0
MySQL Insert Problem

I'm having a very strange problem when submitting data from a PHP form into a MySQL database. You can enter the data in, and it it will act like it has submitted the data to the database, but there is no trace of it. You then re-enter the data into the form and submit it again and it will write it to the database, but the auto increment number has moved on 2 - almost as if it has written and then deleted the previous submission. There is no delete statement in any of the code. The database is on a Unix box and the user access's the database via Citrix.

Reply With Quote
  #2  
Old October 24th, 2005, 03:11 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I suggest putting an or die() command on your mysql_query.
There's a chance your query is failing. Having not seen the code, it's hard to tell.

For example:
$result = mysql_query($sql) or die("MySQL Error ".mysql_errno().": ".mysql_error()."<br>\nThe query was: ".$sql);

How many queries does your action have? Only the one insert query?

Reply With Quote
  #3  
Old October 25th, 2005, 04:05 AM
fezbro fezbro is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 4 fezbro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 44 sec
Reputation Power: 0
There is only one action - here's the code it uses:

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ClientDetails")) {
$insertSQL = sprintf("INSERT INTO clientdetails (FirstName, Surname, DOB, Gender, Address1, Address2, Address3, PostCode, PhoneNumber, MobileNumber, FirstLanguage, DisabilitiesNeeds, EthnicGroup, SourchOfContact, DateOfContact, ContactMade, AgreeToAssessed, CurrentLegalStatus, SentenceLength, Offence1, MainDrug, CurrentTreatment, Treatment, Medication, Prescriber, PrescriberAdd1, PrescriberAdd2, PrescriberPCode, PrescriberTel, PrescriberFax, ContactMadeDetails, LegalStatusDetails, Offence1OtherDetails, OtherDrugDetails, DIRRef, WorkersTel, DateToCC, WorkersName, WorkersLocation, Offence2, Offence2OtherDetails, IntroductionMadeDetails, YesReason, NoReason, YesNoDetails, RefMadeBy, SPOCRecDt, CurLoc, ReleaseDt, DIRStatus, XFer, OtherArea, ExitReason, EXCDate, AssCompDt, FIAccepted, FIRefuseReason, FIRefuseOther, CPDone, CPDoneDt, CDRPArea, OtherUsedDrugs, PPO, HarmMin, BasicSkills, HousingNeeds, `247SPOC`, FTEmpTrain, EpisodeNo, PrisonRelDtd, FINeeded, IntoTreatDt, MainAgency, OthAgency, BasicSkillsRef) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['FirstName'], "text"),
GetSQLValueString($_POST['Surname'], "text"),
GetSQLValueString($_POST['DOBFlip'], "date"),
GetSQLValueString($_POST['Gender'], "text"),
GetSQLValueString($_POST['Address1'], "text"),
GetSQLValueString($_POST['Address2'], "text"),
GetSQLValueString($_POST['Address3'], "text"),
GetSQLValueString($_POST['PostCode'], "text"),
GetSQLValueString($_POST['PhoneNo'], "text"),
GetSQLValueString($_POST['MobileNo'], "text"),
GetSQLValueString($_POST['Language'], "text"),
GetSQLValueString($_POST['SpecialNeeds'], "text"),
GetSQLValueString($_POST['Ethnicity'], "text"),
GetSQLValueString($_POST['Introduction'], "text"),
GetSQLValueString($_POST['IntContactDateFlip'], "date"),
GetSQLValueString($_POST['Contact'], "text"),
GetSQLValueString($_POST['AssessAgree'], "text"),
GetSQLValueString($_POST['LegalStatus'], "text"),
GetSQLValueString($_POST['SentLength'], "text"),
GetSQLValueString($_POST['Offence1'], "text"),
GetSQLValueString($_POST['Drug'], "text"),
GetSQLValueString($_POST['CurrentTreatment'], "text"),
GetSQLValueString($_POST['Treatment'], "text"),
GetSQLValueString($_POST['Medication'], "text"),
GetSQLValueString($_POST['Prescriber'], "text"),
GetSQLValueString($_POST['PrescriberAdd1'], "text"),
GetSQLValueString($_POST['PrescriberAdd2'], "text"),
GetSQLValueString($_POST['PrescriberPCode'], "text"),
GetSQLValueString($_POST['PrescriberTel'], "text"),
GetSQLValueString($_POST['PrescriberFax'], "text"),
GetSQLValueString($_POST['ContactDetails'], "text"),
GetSQLValueString($_POST['LegalStatusOther'], "text"),
GetSQLValueString($_POST['Offence1OtherDetails'], "text"),
GetSQLValueString($_POST['OtherDrug'], "text"),
GetSQLValueString($_POST['DIRRef'], "text"),
GetSQLValueString($_POST['WorkersTel'], "text"),
GetSQLValueString($_POST['DateToCCFlip'], "date"),
GetSQLValueString($_POST['WorkersName'], "text"),
GetSQLValueString($_POST['WorkersLocation'], "text"),
GetSQLValueString($_POST['Offence2'], "text"),
GetSQLValueString($_POST['Offence2OtherDetails'], "text"),
GetSQLValueString($_POST['IntOtherDetails'], "text"),
GetSQLValueString($_POST['YesReason'], "text"),
GetSQLValueString($_POST['NoReason'], "text"),
GetSQLValueString($_POST['AgreeYNDetails'], "text"),
GetSQLValueString($_POST['RefMadeBy'], "text"),
GetSQLValueString($_POST['SPOCRecDtFlip'], "date"),
GetSQLValueString($_POST['CurLoc'], "text"),
GetSQLValueString($_POST['ReleaseDtFlip'], "date"),
GetSQLValueString($_POST['DIRStatus'], "int"),
GetSQLValueString($_POST['XFer'], "int"),
GetSQLValueString($_POST['OtherArea'], "text"),
GetSQLValueString($_POST['ExitReason'], "int"),
GetSQLValueString($_POST['EXCDateFlip'], "date"),
GetSQLValueString($_POST['AssCompDtFlip'], "date"),
GetSQLValueString($_POST['FIAccepted'], "int"),
GetSQLValueString($_POST['FIRefusalReason'], "int"),
GetSQLValueString($_POST['FIRefuseOther'], "text"),
GetSQLValueString($_POST['CPDone'], "int"),
GetSQLValueString($_POST['CPCompDtFlip'], "date"),
GetSQLValueString($_POST['CDRPArea'], "int"),
GetSQLValueString($_POST['OtherUsedDrugs'], "text"),
GetSQLValueString($_POST['PPO'], "int"),
GetSQLValueString($_POST['HarmMin'], "int"),
GetSQLValueString($_POST['BasicSkills'], "int"),
GetSQLValueString($_POST['HousingNeeds'], "int"),
GetSQLValueString($_POST['247SPOC'], "int"),
GetSQLValueString($_POST['FTEmpTrain'], "int"),
GetSQLValueString($_POST['EpisodeNo'], "int"),
GetSQLValueString($_POST['PrisonRelDateFlip'], "text"),
GetSQLValueString($_POST['FINeeded'], "int"),
GetSQLValueString($_POST['IntoTreatDtFlip'], "text"),
GetSQLValueString($_POST['MainAgency'], "int"),
GetSQLValueString($_POST['OthAgency'], "text"),
GetSQLValueString($_POST['BasicSkillsRef'], "int"));
mysql_select_db($database_dip, $dip);
$Result1 = mysql_query($insertSQL, $dip) or die(mysql_error());
//echo $insertSQL;
}

I can't see anything wrong with it - I'm beginning to think the problem is more network related than a MySQL / PHP issue......

Reply With Quote
  #4  
Old December 8th, 2005, 07:41 AM
Laban Laban is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 40 Laban User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 15 m 32 sec
Reputation Power: 4
That is some huge query mate...I'd do the below... I assume you have a decent form setup that sends the values...

PHP Code:
 $value1 $_POST['formFieldName1'];
$value2 $_POST['formFieldName2'];
$value3 $_POST['formFieldName3'];

mysql_query("INSERT INTO table (column1, column2, column3) VALUES ('$value1', '$value2', '$value3')"); 

table = is of course the table you are insterting stuff to
columns1 ,2 ,3 = the columns in the table
$value1, 2, 3 = is the variable you set by $_POST['whatever']

You can of course insert stuff via the query without $value1, 2, 3... the it looks something like this:
PHP Code:
 mysql_query("INSERT INTO table (column1, column2, column3) VALUES ('{$_POST['formFieldName1']}', '{$_POST['formFieldName2']}', '{$_POST['formFieldName3']}')"); 

But personally I like to have the option of formatting stuff before inserting stuff into the database so I use $value1 = {$_POST['formFieldName1']}...might need to strip and format the text before inserting it..


The above doesn't use variables to run the query..it just stuffs the database directly. You can, as you already have, use $insertSQL etc and then run the query by mysql_query.. but I see no reason to complicate it.

Reply With Quote
  #5  
Old December 8th, 2005, 07:57 AM
Laban Laban is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 40 Laban User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 15 m 32 sec
Reputation Power: 4
Quote:
Originally Posted by fezbro
The database is on a Unix box and the user access's the database via Citrix.


Hang on, Citrix doesn't send any data at all... Citrix only sends "images" of what is happening. Unless the website and database is located/runned on the same server you won't get it to work..ever..I think... hmm.... we use Citrix at the office here... but everything is inside the same network.. hmm...

I might have jumped the gun here in my answer but I'll leave it standing anyways as it might get you a little further down the road to success.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > MySQL Insert Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT