Results 1 to 4 of 4

Thread: Data wont save

  1. #1
    Join Date
    Dec 2003
    Posts
    37

    Unanswered: Data wont save

    Hi,

    I started designing a website with php which stores data in mysql database with a web hosting company on a trial package.

    I wrote several scripts and all was working fine. Now I have an proper account with them and none of the "Insert" scripts work. I have checked re checked etc till i'm blue in the face. The only difference I can see is the new one has Collation "latin1_swedish_ci".

    The php form returns no errors it just refreshes the page.

    Any help gratefully received!

    JD

  2. #2
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    This sounds like a permissions problem, but could you post your code or at least the lines of your code with the Insert query string and the query. Are you able to create tables? You might try deleting and recreating the user/password for the database.

  3. #3
    Join Date
    Dec 2003
    Posts
    37
    Hi I made a new script to test incase it was something with php_self the code below inserts a line into the dabase but all fields are blank except hcap which has the null value 0 inserted so the permissions should be ok .

    Thanks
    JD

    Code:
    <?
    
    	$form ="<form action=\"insert.php\" ";
    	$form.= "method =\"get\">";
    	$form.= "Forename      :<input type=\"text\" name=\"Forename\" value=\"$Forename\" ><br>";
            $form.= "Surname       :<input type=\"text\" name=\"Surname\" value=\"$Surname\" ><br>";
    	$form.= "Address Line 1:<input type=\"text\" name=\"Addy_Line1\" value=\"$Addy_Line1\" ><br>";
    	$form.= "Address Line 2:<input type=\"text\" name=\"Addy_Line2\" value=\"$Addy_Line2\" ><br>";
    	$form.= "Address Line 3:<input type=\"text\" name=\"Addy_Line3\" value=\"$Addy_Line3\" ><br>";
    	$form.= "Postcode      :<input type=\"text\" name=\"Postcode\" value=\"$Postcode\" ><br>";
    	$form.= "Phone         :<input type=\"text\" name=\"Phone\" value=\"$Phone\" ><br>";
            $form.= "Handicap      :<input type=\"text\" name=\"Hcap\" value=\"$Hcap\" ><br>";
    	$form.= "<input type=\"submit\" value=\"Submit\">";
    	$form.= "</form>";
    	echo($form);
     ?>
    and the the script it is passed to

    Code:
    <?
    
    	$conn= @mysql_connect ("localhost",*******,"*******")
    	or die ("Error connecting to database. Please try again or contact admin");
    	
    	$db =@mysql_select_db ("jd77_golf",$conn)
    	or die ("Error accessing database");
    
    	$sql = "insert into Member 
    	(Forename,Surname,Addy_Line1,Addy_Line2,Addy_Line3,Postcode,Phone,Hcap)values 
            (\"$Forename\",\"$Surname\",\"$Addy_Line1\",\"$Addy_Line2\",\"$Addy_Line3\",\"$Postcode\",\"$Phone\",\"$Hcap\")";
    
    	
    	 $result = @mysql_query($sql,$conn)
    	 
    	or die("Error inserting data into database please contact admin");
    	
    	if($result) { echo("Member now added to the database") ; }
    ?>

  4. #4
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    This looks like it is a problem with register_globals. In your original script it appears that it is on (the $_GET[....] variables from the form automatically produce the variables by each name), but these variables are empty now, which would indicate that register_globals are off.

Posting Permissions

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