I have I script that when the user inputs a number it will go away and change another rows data, e.g. you enter 1234 and in the other row will change from 'no' to 'yes'. The problem is that the script i have made will let you input anything, even a empty filled it will come back with 'DONE' and not my error message saying that the number entered is not in the DB.
Where is the script i have been using :
$username = "USERNAME";
$password = "PASSWORD";
$database = "DATABASENAME";
$db = mysql_connect("localhost", "$username", "$password");
mysql_select_db("$database",$db);
$result = mysql_query("SELECT * from inputform",$db);
$QUERY01 = "update inputform set invoice='yes' where jobid='$button'";
while ($row = mysql_fetch_array($result)) $in_db[] = $row["jodid"];
if (in_array($button, $in_db)) {
if (mysql_db_query ($database, $QUERY01, $db)) {
print ("<BR><BR>Q1 DONE<BR><BR>");
}
} else { print ("Job Number Not In Database"); }
-----END OF SCRIPT----------
Changing data
Moderator: General Moderators
you could try this:
Code: Select all
if( is_int( $button ) )
{
$query = "update inputform set invoice='yes' where jobid " . $button ;
mysql_query( $query ) or die( $query . "<br>" . mysql_error() ) ;
if( mysql_affected_rows() == 0 )
{
echo "no matching jobid" ;
}
}
else
{
echo "invalid id<br>" ;
}