Hello, I am new to this forum and my name is Maciej. I am not bad with webdesign stuff but I’m having a problem with an php code I have done according to tutorial I found. The code was fully working when it was in its standard form(same as in tutorial, but when I added more VALUES to be added its not working correctly anymore.)
Here is the whole code I have:
[php]
<h1>Reports</h1>
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
<input type="hidden" name="hdnCmd" value="">
<table width="950" border="1">
<tr>
<td width="64">Callsign</td>
<td width="72">Destination</td>
<td width="61">SELCAL</td>
<td width="36">FL</td>
<td width="47">Mach</td>
<td width="89">Current Wpt.</td>
<td width="77">Wpt. ATA</td>
<td width="71">Next Wpt.</td>
<td width="103">Next Wpt. ETA</td>
<td width="112">Wpt. Therafter</td>
<td width="84">Edit</td>
<td width="84">Delete</td>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<?
if($objResult["callsign"] == $_GET["callsign"] and $_GET["Action"] == "Edit")
{
?>
<tr>
<div align="center">
<td>
<input type="text" name="txtEditCallsign" size="6" value="<?=$objResult["callsign"];?>">
<input type="hidden" name="hdnEditCallsign" size="5" value="<?=$objResult["callsign"];?>">
</td>
<td><input type="text" name="txtEditDestination" size="6" value="<?=$objResult["destination"];?>"></td>
<td><input type="text" name="txtEditSelcal" size="6" value="<?=$objResult["selcal"];?>"></td>
<td><input type="text" name="txtEditFL" size="6" value="<?=$objResult["fl"];?>"></td>
<td><input type="text" name="txtEditMach" size="6" value="<?=$objResult["mach"];?>"></td>
<td><input type="text" name="txtEditWpt" size="6" value="<?=$objResult["wpt"];?>"></td>
<td><input type="text" name="txtEditWptAta" size="6" value="<?=$objResult["wptata"];?>"></td>
<td><input type="text" name="txtEditNextWpt" size="6" value="<?=$objResult["nextwpt"];?>"></td>
<td><input type="text" name="txtEditNextWptEta" size="6" value="<?=$objResult["nextwpteta"];?>"></td>
<td><input type="text" name="txtEditNext" size="6" value="<?=$objResult["next"];?>"></td>
<td><input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();"></td>
<td><input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';"></td>
</div>
</tr>
<?php
}
else
{
?>
<tr>
<td><?=$objResult["callsign"];?></td>
<td><?=$objResult["destination"];?></td>
<td><?=$objResult["selcal"];?></td>
<td><?=$objResult["fl"];?></td>
<td><?=$objResult["mach"];?></td>
<td><?=$objResult["wpt"];?></td>
<td><?=$objResult["wptata"];?></td>
<td><?=$objResult["nextwpt"];?></td>
<td><?=$objResult["nextwpteta"];?></td>
<td><?=$objResult["next"];?></td>
<td><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&callsign=<?=$objResult["callsign"];?>">Edit</a></td>
<td><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&callsign=<?=$objResult["callsign"];?>';}">Delete</a></td>
</tr>
<?
}
}
?>
<tr>
<td><input type="text" name="txtAddCallsign" size="6"></td>
<td><input type="text" name="txtAddDestiantion" size="6"></td>
<td><input type="text" name="txtAddSelcal" size="6"></td>
<td><input type="text" name="txtAddFL" size="6"></td>
<td><input type="text" name="txtAddMach" size="6"></td>
<td><input type="text" name="txtAddWpt" size="6"></td>
<td><input type="text" name="txtAddWptAta" size="6"></td>
<td><input type="text" name="txtAddNextWpt" size="6"></td>
<td><input type="text" name="txtAddNextWptEta" size="6"></td>
<td><input type="text" name="txtAddNext" size="6"></td>
<td colspan="2" align="right"><div align="center"><input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();"></div></td>
</tr>
</table>
</form>
<?
mysql_close($objConnect);
?>
[/php]
Here is the live preview: http://www.maciejolborski.net/oceanic/reports.php
So delete function works correctly, but When I try to edit it gives me an error that I dont understand and dont know how to repair:
Error Update [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 ‘callsign = ‘BAW213’,destination = ‘1’ ,fl = ‘390’,mach = ‘.84’ ,wpt = ‘DOGAL’ ,w’ at line 1]
Also when I add records into the database through this form, Destination and Next Wpt. wont add and will show blank.
I will be really thankful for the help!
Maciej.