Jump to content

utterly baffled- update a table


coalduststar

Recommended Posts

Hi

 

I'm trying to update a form to a mysql database- it's simply all text fields except for one integer which is the primar key (auto increment etc)

http://www.arts.ulster.ac.uk/interviews/test.php

http://www.arts.ulster.ac.uk/interviews/thanks3.php

 

test.php holds the form and the recaptcha which all seems to be fine and it posts to thanks3.php which (when i switched to $_GET) is passing the variables to that page but those values are not being stored.

 

I then input my query into the mySQL query browser:

INSERT INTO UCASinterviews VALUES ('','$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');

 

which updated the values i put in but gave this error:

Incorrect integer value: '' for column 'ID' at row 1

 

thanks3.php just won't transfer that info to the table no matter what I try.  I used $_GET, I used PHP_SELF, I stripped the rest of the page away to make sure nothing was  conflicting and now I'm totally stumped- please could someone look at this with fresh eyes?

 

test.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>

<form action="thanks3.php" method="post" id="form2" style="margin-left:15px; display:;">

					<dl id="contform">
                        
                        
                            
                            <dd><label>Name:</label><br />
<input class="padform" type="text" name="name" size="43" maxlength="20" tabindex="2"/></dd>
   <label>UCAS ID:</label><br />
<input class="padform" name="UCAS" type="text" id="UCAS" tabindex="3" size="43" maxlength="30"/></dd> 
  <dd>
  <label>Email:</label><br />
<input class="padform" name="email" type="text" id="email" tabindex="3" size="43" maxlength="30"/></dd>     
<dd>
  <label>Mobile:</label><br />
<input class="padform" name="mob" type="text" id="mob" tabindex="3" size="43" maxlength="30"/></dd>                   
<dd>
  <label>Landline:</label><br />
<input class="padform" name="tel" type="text" id="tel" tabindex="3" size="43" maxlength="30"/></dd>                   
                        
<dd>
  <label>Subject:</label><br />
<select name="subject" tabindex="1" class="padform">
                            	<option value="English">English</option>
                                <option value="European Studies">European Studies</option>
                                <option selected value="Film Studies">Film Studies</option>
                            	<option value="French">French</option>
                            	<option value="German">German</option>
                            	<option value="History">History</option>
                            	<option value="Irish">Irish</option>
                            	<option value="Spanish">Spanish</option>
							<option value="Journalism">Journalism</option>
                            	<option value="Photo Imaging">Photo Imaging</option>
                            	<option value="Media Studies and Production">Media Studies & Production</option>                            
                            	<option value="Interactive Media Arts">Interactive Media Arts</option>                            
                            
                            
                            </select></dd>  
  
<dd><label>Address:</label><br />
  <textarea class="padform"name="address" cols="40" rows="15" id="address" tabindex="5"/>  
  </textarea></dd>
  
   <dd>
  <label>Preferred Interview Date:</label>
  <select name="interviewdate" class="padform">
                                <option value="26/02/11">26 February 2011</option>
                                <option selected value="12/03/11">12 March 2011</option>
  </select>
  </dd>
  <dd>
  <label>Preferred Interview Time:</label>
  <select name="interviewtime" class="padform">
                                <option value="AM">Morning (AM)</option>
                                <option selected value="PM">Afternoon (PM)</option>
  </select>
  </dd>
<dd>
  <label>Parents/Guardians:</label>
  <select name="parents" class="padform">
                                <option value="1">1</option>
                                <option selected value="2">2</option>
  </select>

</dd>
<dd>
  <p>
                 <?php
          require_once('recaptcha/recaptchalib.php');
          $publickey = "6LdU2b4SAAAAAGsh6Z78HjunUL6Mt-ZqCXtIimOs"; // you got this from the signup page
          echo recaptcha_get_html($publickey);
        ?>
                
                </p>

</dd>
                  

						<dd style="background:none;"><input class="btn" type="submit" name="submit" value="Send" tabindex="6" id="submit" /></dd>
  </dl>
      

      
</form>

   
   </div>

</body>
</html>

 

thanks3.php

<?php
  require_once('recaptcha/recaptchalib.php');
  $privatekey = "6LdU2b4SAAAAAN_Z9rLyvle0vb4n4EbyAVyXDa6V";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
  } else {
    // Your code here to handle a successful verification

  require_once("../includes/db_connect.php");


if($_POST['submit']=="true"){
	$name=$_POST['name'];
	$address=$_POST['address'];
	$UCAS=$_POST['UCAS'];
	$mobile=$_POST['mob'];
	$email=$_POST['email'];
	$tel=$_POST['tel'];
	$subject=$_POST['subject'];
	$interviewdate=$_POST['interviewdate'];
	$interviewtime=$_POST['interviewtime'];
	$parents=$_POST['parents'];

	$addEntry="INSERT INTO UCASinterviews VALUES ('','$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');";
	$addResult=mysql_query($addEntry,$db);
}
  }
?>

 

I have other forms working with this near enough the same structure/layout/code - i'm ready to have a coronary!  Is it the database setup? It's same as it ever was myISAM, UTF unicode...

:shrug::wtf:

 

[attachment deleted by admin]

Link to comment
Share on other sites

Incorrect integer value: '' for column 'ID' at row 1

 

Did u set ID column as autoincrement INT??

 

if yes then you have to modify the query and specify each column

INSERT INTO UCASinterviews(name,address,address,UCAS,telephone,email,mobile,subject,interviewdate,interviewtime)VALUES ('$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');

 

hope that will solve the problem

 

Link to comment
Share on other sites

Hi - thanks for the replies but unfortunately that didn't work.

It's meant just to add another record everytime, not update an existing one.

 

This is what I attempted:

 

 <?php
  require_once('recaptcha/recaptchalib.php');
  $privatekey = "6LdU2b4SAAAAAN_Z9rLyvle0vb4n4EbyAVyXDa6V";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
  } else {
    // Your code here to handle a successful verification

  require_once("../includes/db_connect.php");


if($_POST['submit']=="true"){
	$name=$_POST['name'];
	$address=$_POST['address'];
	$UCAS=$_POST['UCAS'];
	$mobile=$_POST['mob'];
	$email=$_POST['email'];
	$tel=$_POST['tel'];
	$subject=$_POST['subject'];
	$interviewdate=$_POST['interviewdate'];
	$interviewtime=$_POST['interviewtime'];
	$parents=$_POST['parents'];

	$addEntry="INSERT INTO UCASinterviews(name,address,UCAS,tel,email,mob,subject,interviewdate,interviewtime,parents)VALUES('$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');";
	$addResult=mysql_query($addEntry,$db);
}
  }
?>

Link to comment
Share on other sites

Echo the query string and make sure the values are what you expect them to be. Then paste it in to phpMyAdmin and see if it executes that way.

$addEntry="INSERT INTO UCASinterviews(name,address,UCAS,tel,email,mob,subject,interviewdate,interviewtime,parents)VALUES('$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');";
//$addResult=mysql_query($addEntry,$db);
echo $addEntry;

Link to comment
Share on other sites

Query string is getting passed to the thanks3.php and being lost before the INSERT somehow. It won't echo the variables but if I use $_GET, they appear as they should in the query string in the top of the browser. :wtf:

 

@robert_gsfame - well spotted but that doesn't seem to have changed anything

@ litebearer- tried this too- doesn't seem to have any bearing

 

:/

 

Link to comment
Share on other sites

Old man rambling (been know to be wrong more times than right)...

 

in your form...

name="submit" value="Send"

in your thanks3

if($_POST['submit']=="true"){

 

(Hopefully Pika will correct me if wrong) :)

 

Good catch, and it also brings up another point. How is it possible that the query is even executing, since it's in a conditional that can't possibly evaluate to TRUE?

 

Are you sure you're editing/uploading the correct file?

Link to comment
Share on other sites

that didn't solve it- the spelling is consistent so it can't be that- i'll have another wee look at the database...

 

 <?php
  require_once('recaptcha/recaptchalib.php');
  $privatekey = "6LdU2b4SAAAAAN_Z9rLyvle0vb4n4EbyAVyXDa6V";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
  } else {
    // Your code here to handle a successful verification

  require_once("../includes/db_connect.php");


if(isset($_POST['Send'])){
	$name=$_POST['name'];
	$address=$_POST['address'];
	$UCAS=$_POST['UCAS'];
	$mob=$_POST['mob'];
	$email=$_POST['email'];
	$tel=$_POST['tel'];
	$subject=$_POST['subject'];
	$interviewdate=$_POST['interviewdate'];
	$interviewtime=$_POST['interviewtime'];
	$parents=$_POST['parents'];

	$addEntry="INSERT INTO UCASinterviews(name,address,UCAS,tel,email,mob,subject,interviewdate,interviewtime,parents)VALUES('$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');";
	$addResult=mysql_query($addEntry,$db);
}
  }
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.