Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    1

    Exclamation Unanswered: Newbie - Getting Warnings.

    Hello all,
    I'm new to mysql, but I've managed to cobble together a script that does everything exactly as I want it to. The problem is I'm getting Warnings when I run through certain loops in the script, but I don't see any errors.

    Here is the warning:

    Code:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.fitch/awkemp/kempa.com/aadl/index.phtml on line 33
    ...and here is the general area of line 33 in the code:


    Code:
    if ($endses) {
    
    		if (!$stationnumber || strlen($stationnumber) > 1 || $stationnumber > 3 || ereg("^[[:alpha:]]$", $stationnumber) || ereg("^[-!#@$%&\'\;:<>?\|*~+\\./0-]$", $stationnumber)){
    			echo "<center>Invalid station number entered.<P><a href=\"index.phtml\">Back</a></center>";
    		}
    		else{
    	
    			$result = mysql_query("SELECT * FROM stations",$db);
    		
    			while($myrow = mysql_fetch_array($result)){ 
    
    				if ($myrow["id"] == $stationnumber && $myrow["status"] != 'Out of order') {
    		
    					echo "<center>Session Ended.<P>";
    				
    					echo "<a href=\"index.phtml\">Back</a><P></center>\n";
    		
    					$id = $myrow["id"]; 
    
    					$sql = "UPDATE stations SET cardnumber=NULL,last=NULL,first=NULL,status='Available' WHERE id=$id";
    
    					$result = mysql_query($sql,$db); 
    				}
    		
    				else{
    				
    					if ($myrow["id"] == $stationnumber) {
    				
    						echo "<center>Station is out of order. No session exists.<P><a href=\"index.phtml\">Back</a></center>";
    				
    					}
    				}
    
    			}
    		
    		}
    	}
    Any Suggestions?
    I can post the rest of the code if neccesary.
    Thanks!
    Adam

  2. #2
    Join Date
    Jul 2004
    Location
    Dundee, Scotland
    Posts
    107
    is your code in a function? have you made $result a global?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •