Jump to content

Update Issues


cdoggg94

Recommended Posts

Okay, so I have a few questions.

 

This is my Update script:

 

<?php


echo $_GET['Client'];


$con = mysql_connect("localhost","root","");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }


mysql_select_db("my_db", $con);


mysql_query("UPDATE quote_tbl 
SET contact_id='".$row_Info['contact_id']."',
F1='".$row_Info['F1']."',
contact_contact='".$row_Info['contact_contact']."',
contact_FirstName='".$row_Info['contact_FirstName']."',
contact_LastName='".$row_Info['contact_LastName']."',
contact_Phone='".$row_Info['contact_Phone']."',
contact_phone2='".$row_Info['contact_phone2']."',
contact_Fax='".$row_Info['contact_fax']."',
contact_Street1='".$row_Info['contact_Street1']."',
lawn_size='".$row_Info['lawn_size']."',
quote_visitFee='".$_POST['visitFee']."',
quote_visitsPerDay='".$_POST['visitDay']."',
quote_hoursPerDay='".$_POST['dailyHours']."',
quote_timePerVisit='".$_POST['timePerVisit']."',
quote_gasCostPerDay='".$_POST['gasPerDay']."',
quote_smallMaint='".$_POST['smallMaint']."'',
quote_largeMain='".$_POST['largeMain']."',
quote_largeMainPerYear='".$_POST['costPerYear']."',
quote_speader='".$_POST['speader']."',
quote_tank='".$_POST['Tank']."',
quote_wands='".$_POST['wands']."',
quote_Ins='".$_POST['insCost']."',
quote_insCostPerYear='".$_POST['insPerYear']."',
quote_vehicle='".$_POST['vehicleCost']."',
quote_vehicleCostPerYear='".$_POST['vehiclePerYear']."',
quote_liabilityIns='".$_POST['liabilityCost']."',
quote_liabilityCostPerYear='".$_POST['liabilityPerYear']."',
quote_WandTDay='".$_POST['WandTCost']."',
quote_WandTperVisit='".$_POST['WandTperVisit']."',
quote_LabourPerJob='".$_POST['labourPerJob']."',
quote_managementAdmin='".$_POST['ManagementAdmin']."',
quote_PervisitCost='".$_POST['perVisitCost']."'


WHERE contact_id='".$_GET['Client']."'");


mysql_close($con);
?>

 

The format i was using is like this:

 

mysql_query("UPDATE quote_tbl SET contact_id='sometihng1', F1='something2', contact_contact='something3' WHERE contact_id='Number'");

 

I was wondering if the single quotes were needed for the values or not ?

 

Or if there was something obviously wrong with what I have above.

 

Any Help would be appreciated!

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/270993-update-issues/
Share on other sites

This is the Form that goes along with it :

 

<form action="quote_generator2.php?Client=<?php echo $_GET['Client'] ;?>" method="POST" id="quote" name="quote">
<table width="589" border="0">
<tr>
    <th colspan="2">General</th>
</tr>
<tr>
    <td width="164" align="right">Fiesta %:</td>
       <td width="415"><input name="fiestaPercent" type="text" /></td>
</tr>


<tr>
    <th colspan="2"><br />Cost/Year</th>
</tr>
<tr>
    <td width="164" align="right">Mad/admin:</td>
       <td width="415"><input name="madAdmin" type="text" /></td>
</tr>
   <tr>
    <td align="right">% of Man/admin:</td>
       <td><input name="percentManAdmin" type="text" /></td>
</tr>
<tr>
    <th colspan="2">Visits</th>
</tr>
<tr>
    <td align="right">Visit Fee:</td>
       <td><input name="visitFee" type="text" /></td>
</tr>
   <tr>
    <td align="right">Visits/day:</td>
       <td><input name="visitDay" type="text" /></td>
</tr>
   <tr>
    <td align="right">Hours/day:</td>
       <td><input name="dailyHours" type="text" /></td>
</tr>
   <tr>
    <th colspan="2"><br />Gas</th>
</tr>
   <tr>
    <td align="right">Gas Cost/day:</td>
       <td><input name="gasPerDay" type="text" /></td>
</tr>
   <tr>
    <td align="right">Average km/day:</td>
       <td><input name="kmPerDay" type="text" /></td>
</tr>
   <tr>
    <td align="right">Gas price/ltr:</td>
       <td><input name="gasPrice" type="text" /></td>
</tr>
   <tr>
    <td align="right">Vehicle km/ltr:</td>
       <td><input name="mileage" type="text" /></td>
</tr>
   <tr>
    <th colspan="2"><br />Costs</th>
</tr>
   <tr>
    <td align="right">Cost/day:</td>
       <td><input name="costPerDay" type="text" /></td>
</tr>
   <tr>
    <td align="right">Small Maint:</td>
       <td><input name="smallMaint" type="text" /></td>
</tr>
   <tr>
    <td align="right">Cost/Year:</td>
       <td><input name="costPerYear" type="text" /></td>
</tr>
   <tr>
    <td align="right">Speader:</td>
       <td><input name="speader" type="text" /></td>
</tr>
   <tr>
    <td align="right">Tank:</td>
       <td><input name="Tank" type="text" /></td>
</tr>
   <tr>
    <td align="right">Wands:</td>
       <td><input name="wands" type="text" /></td>
</tr>
   <tr>
    <td align="right">Ins Cost/Year:</td>
       <td><input name="insPerYear" type="text" /></td>
</tr>
   <tr>
    <td align="right">Vehicle Cost/Year:</td>
       <td><input name="vehiclePerYear" type="text" /></td>
</tr>
   <tr>
    <td align="right">Liability Ins Cost/Year:</td>
       <td><input name="liabilityPerYear" type="text" /></td>
</tr>


   <th colspan="2"><br />Labour</th>
</tr>
<tr>
    <td align="right">Man 1:</td>
       <td><input name="man1" type="text" /></td>
</tr>
   <tr>
    <td align="right">Man 2:</td>
       <td><input name="man2" type="text" /></td>
</tr>


    <th colspan="2"><br />Products</th>
</tr>
<tr>
    <td align="right">Fiesta:</td>
       <td><input name="fiestaBase" type="text" /></td>
</tr>
   <tr>
    <td align="right">Fert:</td>
       <td><input name="fertBase" type="text" /></td>
</tr>
   <tr>
    <td align="right">Corn Gluten Meal:</td>
       <td><input name="cornBase" type="text" />   Mark Up:<input name="cornMarkUp" type="text" /></td>
</tr>
   <tr>
    <td align="right">Sea Kelp:</td>
       <td><input name="seaBase" type="text" /></td>
</tr>
   <tr>
    <td align="right">Seed 1:</td>
       <td><input name="seedBase" type="text" />   Mark Up:<input name="seedMarkUp" type="text" /></td>
</tr>
   <tr>
    <td align="right">Grubs:</td>
       <td><input name="grubBase" type="text" />   Mark Up:<input name="grubMarkUp" type="text" /></td>
</tr>
   <tr>
    <td align="right">Aeration (sq/ft cost):</td>
       <td><input name="aerationBase" type="text" />   Mark Up:<input name="aerationMarkUp" type="text" /></td>
</tr>


   <th colspan="2"><br />Adjustments</th>
</tr>
<tr>
    <td align="right">Markup:</td>
       <td><input name="markUp" type="text" /></td>
</tr>


   <tr>
    <td align="right">
       <input name="yardSizeSQ" type="hidden" value="<?php echo $row_Info['lawn_size'];?>" />
       <input name="timePerVisit" type="hidden" value="<?php echo ($_POST['dailyHours'])/($_POST['visitDay']) ;?>" />
       <input name="gasPerDay" type="hidden" value="<?php echo (($_POST['kmPerDay'])/($_POST['gasPrice']))*$_POST['mileage'] ;?>" />
       <input name="largeMain" type="hidden" value="<?php echo $_POST['costPerYear']/365 ;?>" />
       <input name="insCost" type="hidden" value="<?php echo $_POST['insPerYear']/365 ;?>" />
       <input name="vehicleCost" type="hidden" value="<?php echo $_POST['vehiclePerYear']/365 ;?>" />
       <input name="liabilityCost" type="hidden" value="<?php echo $_POST['liabilityPerYear']/365 ;?>" />
       <input name="WandTCost" type="hidden" value="<?php echo 
 ($_POST['gasPerDay'])+ 
 ($_POST['smallMaint'])+
 ($_POST['largeMain'])+
 ($_POST['speader'])+
 ($_POST['Tank'])+
 ($_POST['wands'])+
 ($_POST['insCost'])+
 ($_POST['vehicleCost'])+
 ($_POST['liabilityCost']); 
 ?>" />
       <input name="man1Cost" type="hidden" value="<?php echo ($_POST['man1'])/($_POST['timePerVisit']) ;?>" />
       <input name="man2Cost" type="hidden" value="<?php echo ($_POST['man2'])/($_POST['timePerVisit']) ;?>" />
       <input name="jobCost" type="hidden" value="<?php echo ($_POST['man1Cost'])+($_POST['man2Cost']) ;?>" />
       <input name="WandTperVisit" type="hidden" value="<?php echo ($_POST['WandTCost'])/($_POST['visitDay']) ;?>" />
       <input name="labourPerJob" type="hidden" value="<?php echo $_POST['jobCost'] ;?>" />
       <input name="ManagementAdmin" type="hidden" value="<?php echo ((($_POST['madAdmin'])/($_POST['percentManAdmin']))/($_POST['visitDay'])) ;?>" />
       <input name="perVisitCost" type="hidden" value="<?php echo 
 ($_POST['WandTperVisit'])+ 
 ($_POST['labourPerJob'])+
 ($_POST['ManagementAdmin']); 
 ?>" />
       <input name="fiestaSQprice" type="hidden" value="<?php echo ($_POST['fiestaBase'])/2700 ;?>" />
       <input name="fiestaAppCost" type="hidden" value="<?php echo (($row_Info['lawn_size'])*($_POST['fiestaPercent']))*($_POST['fiestaSQprice']) ;?>" />
       <input name="fertSQprice" type="hidden" value="<?php echo ($_POST['fertBase'])/1000 ;?>" />
       <input name="fertAppCost" type="hidden" value="<?php echo ($row_Info['lawn_size'])*($_POST['fertSQprice']) ;?>" />
       <input name="cornSQprice" type="hidden" value="<?php echo ($_POST['cornBase'])/4000 ;?>" />
       <input name="cornAppCost" type="hidden" value="<?php echo ($row_Info['lawn_size'])*($_POST['cornSQprice']) ;?>" />
       <input name="seedSQprice" type="hidden" value="<?php echo ($_POST['seedBase'])/10000 ;?>" />
       <input name="seedAppCost" type="hidden" value="<?php echo ($row_Info['lawn_size'])*($_POST['seedSQprice']) ;?>" />
       <input name="grubSQprice" type="hidden" value="<?php echo ($_POST['grubBase'])/11000 ;?>" />
       <input name="grubAppCost" type="hidden" value="<?php echo ($row_Info['lawn_size'])*($_POST['grubSQprice']) ;?>" />
       <input name="aerationAppCost" type="hidden" value="<?php echo ($row_Info['lawn_size'])*($_POST['aerationBase']) ;?>" />

       </td>
       <td><input name="Generate Quote" type="submit" id="Generate Quote" value="Submit" /></td>
</tr>
</table>
</form>

 

does the form need: enctype="multipart/form-data"?

Link to comment
https://forums.phpfreaks.com/topic/270993-update-issues/#findComment-1394131
Share on other sites

Yep, something is wrong...

 

i dont really get what its trying to tell me is wrong though

 

"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 '0', quote_largeMainPerYear='1200', quote_speader='2', quote_tank='2', quote_wand' at line 17"

Link to comment
https://forums.phpfreaks.com/topic/270993-update-issues/#findComment-1394159
Share on other sites

Replace your query block with the following:

 

$sql = "
   UPDATE quote_tbl 
   SET
       contact_id='".$row_Info['contact_id']."',
       F1='".$row_Info['F1']."',
       contact_contact='".$row_Info['contact_contact']."',
       contact_FirstName='".$row_Info['contact_FirstName']."',
       contact_LastName='".$row_Info['contact_LastName']."',
       contact_Phone='".$row_Info['contact_Phone']."',
       contact_phone2='".$row_Info['contact_phone2']."',
       contact_Fax='".$row_Info['contact_fax']."',
       contact_Street1='".$row_Info['contact_Street1']."',
       lawn_size='".$row_Info['lawn_size']."',
       quote_visitFee='".$_POST['visitFee']."',
       quote_visitsPerDay='".$_POST['visitDay']."',
       quote_hoursPerDay='".$_POST['dailyHours']."',
       quote_timePerVisit='".$_POST['timePerVisit']."',
       quote_gasCostPerDay='".$_POST['gasPerDay']."',
       quote_smallMaint='".$_POST['smallMaint']."'',
       quote_largeMain='".$_POST['largeMain']."',
       quote_largeMainPerYear='".$_POST['costPerYear']."',
       quote_speader='".$_POST['speader']."',
       quote_tank='".$_POST['Tank']."',
       quote_wands='".$_POST['wands']."',
       quote_Ins='".$_POST['insCost']."',
       quote_insCostPerYear='".$_POST['insPerYear']."',
       quote_vehicle='".$_POST['vehicleCost']."',
       quote_vehicleCostPerYear='".$_POST['vehiclePerYear']."',
       quote_liabilityIns='".$_POST['liabilityCost']."',
       quote_liabilityCostPerYear='".$_POST['liabilityPerYear']."',
       quote_WandTDay='".$_POST['WandTCost']."',
       quote_WandTperVisit='".$_POST['WandTperVisit']."',
       quote_LabourPerJob='".$_POST['labourPerJob']."',
       quote_managementAdmin='".$_POST['ManagementAdmin']."',
       quote_PervisitCost='".$_POST['perVisitCost']."'
   WHERE contact_id='".$_GET['Client']."'
";
if ($result = mysql_query($sql)) {
   if (mysql_affected_rows() > 0) {
       // update successful; do something;
   } else {
       // update NOT successful; do something;
   }
} else {
   echo $sql .'<br/><br/>'. mysql_error();
}

Link to comment
https://forums.phpfreaks.com/topic/270993-update-issues/#findComment-1394170
Share on other sites

UPDATE quote_tbl SET contact_id='733', F1='', contact_contact='colin2 value=', contact_FirstName='colin2', contact_LastName='zepping', contact_Phone='5195504946', contact_phone2='5195504946', contact_Fax='', contact_Street1='545 bekmont ave west', lawn_size='500x500', quote_visitFee='35', quote_visitsPerDay='12', quote_hoursPerDay='9', quote_timePerVisit='', quote_gasCostPerDay='0', quote_smallMaint='2'', quote_largeMain='0', quote_largeMainPerYear='1200', quote_speader='2', quote_tank='2', quote_wands='2', quote_Ins='0', quote_insCostPerYear='1300', quote_vehicle='0', quote_vehicleCostPerYear='8000', quote_liabilityIns='0', quote_liabilityCostPerYear='1000', quote_WandTDay='0', quote_WandTperVisit='', quote_LabourPerJob='', quote_managementAdmin='', quote_PervisitCost='0' WHERE contact_id='733'

 

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 '0', quote_largeMainPerYear='1200', quote_speader' at line 18

 

so it looks like it only getting content for SOME of the $_post values..

Link to comment
https://forums.phpfreaks.com/topic/270993-update-issues/#findComment-1394176
Share on other sites

UPDATE quote_tbl
SET contact_id='733',
F1='',
contact_contact='colin2 value=',
contact_FirstName='colin2',
contact_LastName='zepping',
contact_Phone='5195504946',
contact_phone2='5195504946',
contact_Fax='',
contact_Street1='545 bekmont ave west',
lawn_size='500x500',
quote_visitFee='35',
quote_visitsPerDay='12',
quote_hoursPerDay='9',
quote_timePerVisit='',
quote_gasCostPerDay='0',
quote_smallMaint='2'',
quote_largeMain='0',
quote_largeMainPerYear='1200',
quote_speader='2',
quote_tank='2',
quote_wands='2',
quote_Ins='0',
quote_insCostPerYear='1300',
quote_vehicle='0',
quote_vehicleCostPerYear='8000',
quote_liabilityIns='0',
quote_liabilityCostPerYear='1000',
quote_WandTDay='0',
quote_WandTperVisit='',
quote_LabourPerJob='',
quote_managementAdmin='',
quote_PervisitCost='0'
WHERE contact_id='733'

 

The above should show where the problem is occurring.

Link to comment
https://forums.phpfreaks.com/topic/270993-update-issues/#findComment-1394179
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.