shadowspy1 Posted July 8, 2007 Share Posted July 8, 2007 I have been making great progress till this point. I've been stuck here for two days. My code doesn't not want to insert into he MYSQL database, although I have various other code throughout my site that does. Maybe I just overlooked somethng. Here is the main form: elseif ($section == 'flight'){ ?> <label> <div align="center"> <form name="bidprocess" method="get" action="submitbid.php"> <center><p> <? $sql = "SELECT * FROM availbid WHERE flightnum = '$flight'"; $result = mysql_query($sql); $stats = mysql_fetch_array($result); ?> You are about to submit the following bid:</p> </center> <table width="516" border="0" align="center"> <tr> <td width="216" bgcolor="#FFFFFF" class="style1"><div align="right"><span class="style5">Flight:</span></div></td> <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["flightnum"];?></span></td> </tr> <tr> <td class="style5"><div align="right">Departing:</div></td> <td width="290" class="style1"><span class="style1"><? echo $stats["departure"];?></span></td> </tr> <tr> <td bgcolor="#FFFFFF"><div align="right"><span class="style5"> Departure Time:</span></div></td> <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["deptime"];?></span></td> </tr> <tr> <td bgcolor="#FFFFFF" class="style5"><div align="right">Arriving:</div></td> <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["arrival"];?></span></td> </tr> <tr> <td bgcolor="#FFFFFF" class="style5"><div align="right">Arrival Time:</div></td> <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["arrtime"];?></span></td> </tr> <tr> <td bgcolor="#FFFFFF" class="style5"><div align="right">Aircraft:</div></td> <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["equipment"];?></span></td> </tr> </table> <? if(isset($pilotid)){ ?> <input type="submit" name="Submit" value="Submit Bid"> </label> <? } } ?> Followed by the action script: <?php $pilotid = $_SESSION['pilotid']; $flight = $_GET['flightnum']; $aircraft = $_GET['equipment']; $departure = $_GET['departure']; $deptime = $_GET['deptime']; $arrival = $_GET['arrival']; $arrtime = $_GET['arrtime']; $sql = "INSERT INTO takenbid (pilotid,flightnum, equipment, departure, deptime, arrival, arrtime) VALUES('$pilotid','$flightnum','$equipment','$departure','$deptime','$arrival','$arrtime')"; mysql_query($sql) ?> Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted July 8, 2007 Share Posted July 8, 2007 Add "or die(mysql_error())" to your query and post us the error mysql_query($sql) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 8, 2007 Author Share Posted July 8, 2007 Nothing is showing up. All I get is a blank page. Quote Link to comment Share on other sites More sharing options...
OLG Posted July 8, 2007 Share Posted July 8, 2007 Dare i be so rude as to ask whether in submitbid.php you are connecting to the database? Additionally for your VALUES('$pilotid' i would reccomend doing the following VALUES({$pilotid} to prevent injection since this is "monetary". Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 8, 2007 Author Share Posted July 8, 2007 The connection info is in there, I just didn't feel like showing it. Also, pilotid is like the user id, just a auto incrementing integer. Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted July 8, 2007 Share Posted July 8, 2007 Then please try this: $result = mysql_query($sql); if($result) { echo "Success..."; } else { echo "Failure..."; } Just to see what the result of the query is, if it returns true as in success or false as in failure... Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 8, 2007 Author Share Posted July 8, 2007 Unfortunately, nothing here. Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 8, 2007 Author Share Posted July 8, 2007 I think I may have found more of the problem. It seems the variables that I declared aren' transferring to the action page. Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted July 8, 2007 Share Posted July 8, 2007 Well it shouldn't correct your problem, it should tell you whether or not the query succeeded or not. What was the outcome? Success or failure? Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 8, 2007 Author Share Posted July 8, 2007 Didn't show anything, still a blank white page. Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 9, 2007 Author Share Posted July 9, 2007 Ok, i was missing a semicolon earlier in my script, my bad. It says success, however, when I go to insert the data, it puts in the correct pilotid, flightnum = 0, and all the others are blank. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Immediately before mysql_query($sql); add this line: echo 'SQL='.$sql; Try that and paste the output here. This will tell you exactly what query is being used. Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 9, 2007 Author Share Posted July 9, 2007 SQL=INSERT INTO takenbid (pilotid, flightnum, equipment, departure, deptime, arrival, arrtime) VALUES('100','','','','','','') Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 9, 2007 Share Posted July 9, 2007 SQL=SELECT * FROM availbid WHERE flightnum = so i hope you know that the condition is getting on empty values ??? Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 9, 2007 Author Share Posted July 9, 2007 Sorry teng, I modified it, or at least tried to, and modified it right before you posted. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 How can you be given a SELECT query when you're populating $sql with an INSERT query??? Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 9, 2007 Author Share Posted July 9, 2007 I was trying something before I realized where to post it. I changed it back to the original and posted the code that you suggested. That's why you see that modified one in his quote. I realized my mistake. SQL=INSERT INTO takenbid (pilotid, flightnum, equipment, departure, deptime, arrival, arrtime) VALUES('100','','','','','','') Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Scrub that I read teng's reply and misread it. Now you can see that your INSERT isn't adding any data because the patr of the script that reads the data isn't working. You've got the form set to GET which is correct but I can't see where you're building the input tags for the form? Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 9, 2007 Author Share Posted July 9, 2007 If I understand your question correctly, I'm thinking I should put the variables in the link on addition to the submitbid.php?=flightnum=101 etc.... Please correctly me if I'm wrong. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Yes unless you're getting data from a form? I see you're pulling data from a table at the start of your first script but going by the form you've set up you've only created a submit button - nowhere to supply input. You can either passthe data in the URL (insecure as users can simply edit the URL) or by sending via $_POST as packets of data when they click the submit button. Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 9, 2007 Author Share Posted July 9, 2007 How would I go about send the packets, which I assume is the more secure way? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 You can use HTML like this in your form: <input type="hidden" name="customer" value="<?=$customername?>" /> Is the data you're wanting the send the same data that is in the query you're pulling from the table? Quote Link to comment Share on other sites More sharing options...
shadowspy1 Posted July 9, 2007 Author Share Posted July 9, 2007 Yeah, I'm trying to give a review page before they finally submit it. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 You can use the hidden input tags like I specified above to retain the data. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Here's an example to get you going... <td width="290" bgcolor="#FFFFFF" class="style1"><span class="style1"><? echo $stats["flightnum"];?></span><input type="hidden" name="flightnum" value="<?=$stats['flightnum']?>" /></td> It's 3:15am now amd I'm having to get some sleep... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.