[thelist] Null entry in form
Tris
beertastic at gmail.com
Wed Apr 25 05:32:11 CDT 2007
Why not use a score of 99-99 to signify a null game?
then at least you've not got to worry abuut null?
just a thought, and I'm hubgover, so sorry if it's a stupid thought...
On 25/04/07, Santilal Parbhu <santilal at scorpioneng.co.nz> wrote:
> Hi
>
> I am developing an appliciation in PHP4. I use a form to collect results
> from sports matches. If the match has been played and the results have been
> entered, those results are stored in a MySQL database. The default value is
> NULL. Later I query the database and will use the data to update a points
> table. If the games haven't been played, the match is ignored.
>
> I read a form and the way I determine if the the results have been entered
> is to look to see if the form has a value in it. If the value is NULL, then
> the results are not entered. (I was using 0-0 as a means of detecting that
> the game has not been played, but then I realised that 0-0 can be a valid
> result.)
>
> My problem is that when I run the script to update the results into the
> database, the database record changes from Null to a value of 0. This
> should occur for non-null entries but not for Null entries. I need a null
> entry to remain Null. Can anyone see where my code is in error? I think
> that the UPDATE is not being skipped and the NULL is being updated to 0.
>
> I have tried using Print statements as breakpoints in the code, but they
> didn't print. This tens to suggest that the code is not running, but it
> must be, because the database is being updated. Hope someone can help.
>
> Thanks.
>
> Santilal
>
> foreach($HTTP_POST_VARS['match_id'] as $id){
> $score1=$HTTP_POST_VARS['score1'][$id]; //Read in the value of Score 1
> from the form.
> $score2=$HTTP_POST_VARS['score2'][$id]; //Read in the value of Score 2
> from the form.
>
> if ((isset($score1)) or (isset($score2))) { //If either Score1 or Score2
> is not NULL, run the update.
>
> $query = "UPDATE $compdraw SET score1=('$score1'), score2=('$score2')
> WHERE row_id = '$id' AND grade='$grd'";
>
> if($r = mysql_query ($query)){ // Execute the query.
> }else{ // Query didn't run.
> print '<div id="draw">';
> die ('<p>Could not retrieve the data because: <b>' . mysql_error() .
> "</b>. The query was $query.</p>");
> }
> }
> }
>
>
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
--
When a person can no longer laugh at himself, it is time for others to
laugh at him.
Thomas Szasz
More information about the thelist
mailing list