Hi,
Having some trouble with a script im writing. I keep getting the error 'query was empty'. I have written a successful script to insert data about asset tracking into my database, but im having trouble updating it!
This i the form the new data is coming from:
<html>
<body>
<form name ="UPDATEASSET" form action= "UPDATEASSETTRACK.php" method="post">
ID:
<BR/>
<input type= "text" Name="ASSETID" ID="ASSETID"><br>
Type:
<br/>
<select name= "DROPDOWN">
<option value= "">--</option>
<option value= "SERVER">Server</option>
<option value= "DESKTOP">Desktop</option>
<option value= "LAPTOP">Laptop</option>
<option value="PRINTER">Printer</option>
<option value="SCANNER">Scanner</option>
<option value="VISUALISER">Visualiser</option>
<option value="MONITOR">Monitor</option>
<option value="TELEVISION">Television</option>
<option value="NETWORKING">Networking Equipment</option>
<option value="PHONE">Phone</option>
</select>
<br/>
Make:
<br/>
<input type= "text" Name= "MAKE" id= "MAKE" ><br>
Model:
<br/>
<input type= "text" Name= "MODEL" id= "MODEL" ><br>
Serial:
<br/>
<input type= "text" Name= "SERIAL" id=" "SERIAL" ><br>
Value:
<br/>
<input type= "text" Name= "VALUE" id= "VALUE" ><br>
Location:
<br/>
<input type= "text" Name= "LOCATION" id= "LOCATION"><br>
<h1><input type= "submit" Name= "submit" Value="UPDATE" ></h1>
</form>
<br>
</body>
</html>
------------------------------------------
and this is the PHP script:
------------------------------------------
<?php
//create a connection to the database
$con = mysql_connect("localhost", "root", "root");
if (!$con)
{
die ('could not connect: '. mysql_error());
}
mysql_select_db("3355405", $con);
//sent from updateasset
$ASSETID= $_POST["ASSETID"];
$TYPE= $_POST["DROPDOWN"];
$MAKE= $_POST["MAKE"];
$MODEL= $_POST["MODEL"];
$SERIAL= $_POST["SERIAL"];
$VALUE= $_POST["VALUE"];
$LOCATION= $_POST["LOCATION"];
//Update the assets from UPDATEASSET
mysql_query("UPDATE assettracking SET
TYPE= '$TYPE', MAKE ='$MAKE', MODEL='$MODEL',SERIAL='$SERIAL',
VALUE='$VALUE', LOCATION ='$LOCATION'
WHERE ASSETID = '$ASSETID'");
//catch some errors
if (!mysql_query($sql, $con))
{
die('Error: ' .mysql_error());
}
echo "Your Data has been added to the DataBase, Thank You.";
mysql_close($con)
?>
Hopefully somebody can shed some light on this, as im sure its an obvious error to an experienced coder.
Thanks
Harry
Query is empty
Moderator: General Moderators
Re: Query is empty
Once again, i have solved a problem i have been stuck on for a whole day in a matter of minutes of posting this request. Sorry for clogging up the forum.
For anyone who is experiencing this problem i changed the sql from:
//Update the assets from UPDATEASSET
mysql_query("UPDATE assettracking SET
TYPE= '$TYPE', MAKE ='$MAKE', MODEL='$MODEL',SERIAL='$SERIAL',
VALUE='$VALUE', LOCATION ='$LOCATION'
WHERE ASSETID = '$ASSETID'");
to:
$sql=("UPDATE assettracking
SET
TYPE= '$TYPE', MAKE ='$MAKE', MODEL='$MODEL', SERIAL='$SERIAL',
VALUE='$VALUE', LOCATION ='$LOCATION'
WHERE ASSETID = '$ASSETID' ");
and it now works.
Thanks
For anyone who is experiencing this problem i changed the sql from:
//Update the assets from UPDATEASSET
mysql_query("UPDATE assettracking SET
TYPE= '$TYPE', MAKE ='$MAKE', MODEL='$MODEL',SERIAL='$SERIAL',
VALUE='$VALUE', LOCATION ='$LOCATION'
WHERE ASSETID = '$ASSETID'");
to:
$sql=("UPDATE assettracking
SET
TYPE= '$TYPE', MAKE ='$MAKE', MODEL='$MODEL', SERIAL='$SERIAL',
VALUE='$VALUE', LOCATION ='$LOCATION'
WHERE ASSETID = '$ASSETID' ");
and it now works.
Thanks