Page 1 of 1

Changing data

Posted: Mon Apr 29, 2002 3:11 am
by glenn
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----------

Posted: Mon Apr 29, 2002 9:19 am
by nahp
you could try this:

Code: Select all

if( is_int( $button ) )
&#123;
  $query = "update inputform set invoice='yes' where jobid " . $button ;
  mysql_query( $query ) or die( $query . "<br>" . mysql_error() ) ;
  if( mysql_affected_rows() == 0 )
  &#123;
    echo "no matching jobid" ;
  &#125;
&#125;
else
&#123;
  echo "invalid id<br>" ;
&#125;

Posted: Tue Apr 30, 2002 4:16 am
by glenn
Thanks for the help.

Its sort of working, it prints "invalid id" whatever i input, even when i input a number in my db, but when i do input a number from my db it does change, but still prints invalia id.


but thanks iam looking into what the 'is_int' function can do

Glenn

Posted: Wed May 01, 2002 3:22 am
by glenn
It's ok now thanks for the code nahp, I have changed the code and it now works 100%

Thanks Glenn