Jump to content

Recommended Posts

My database was working fine (for test purposes) a week ago.  Now, it will not record data input from my forms.

If I add a new record, it adds the record, but none of the data.

If I update a record, it erases the values.

 

The forms and attached scripts have NOT undergone any changes, and they DO provide SUCCESS messages.

 

Ideas?

Link to comment
https://forums.phpfreaks.com/topic/258062-db-does-not-record-data/
Share on other sites

I will start posting code if I have to, but first, the only "adjustment" made to the actual database was that I may have added to columns (at various locations between others) and then I later deleted them. 

I have since replaced them as a troubleshooting technique, but their NAMES are NOT receiving any values (which is why I removed them in the first place).

 

Does this sort of manuever affect the tables?? 

 

(I'm a newbie, so maybe I just messed it up... LOL)

The kind of problems that could be caused by adding or removing columns in a table would (most likely) not produce these symptoms -- they would likely produce errors, but the database would not be updated (or inserted).

 

If your mySql (server software) was upgraded or the PHP engine (software) was upgraded; changes in the configuration could be affecting this. For instance: if register_globals was ON before and is now OFF any PHP code that depends on registered globals will fail.

 

If you post the code that receives the form data we might be able to suggest some areas that may be causing problems.

 

CONNECT

if(isset($_POST['action']) && $_POST['action'] == 'submitform')

{

$roastturkey = $_POST['roastturkey'];

$broccoli = $_POST['broccoli'];

$brisket = $_POST['brisket'];

$carrots = $_POST['carrots'];

}

 

$sql = "INSERT INTO pass (roastturkey,broccoli,brisket,carrots) VALUES ('$roastturkey','$broccoli','$brisket','$carrots')";

 

$result=mysql_query($sql);

 

if($result){

echo "Successful";

}else {

echo "ERROR";

}

 

Fairly simple, I think, and it used to work.

 

** Disclaimer: Not responsible if this code causes hunger or urges to snack **

WOW!  found the same line of code in my UPDATE script.  Took it out and I'm working fine now.

 

Thanks a TON! 

 

(i think i'll quit while ahead... LOL)

 

So what EXACTLY is that line saying?

 

And is it necessary in one way or another as a double-check process of the form?

if (isset($_POST['action']) && $_POST['action'] == 'submitform')",

 

isset checks to see if $POST['action'] has a value

 

so you're basiclly saying, if (action has a value) & (that value equals submitform) run the following script

 

heres how I do my submits

 

f (isset($_POST['submit'])){ 
$roastturkey = $_POST['roastturkey'];
$broccoli = $_POST['broccoli'];
$brisket = $_POST['brisket'];
$carrots = $_POST['carrots'];

$sql = "INSERT INTO pass (roastturkey,broccoli,brisket,carrots) VALUES ('$roastturkey','$broccoli','$brisket','$carrots')";
$result=mysql_query($sql); 

if($result){
    echo "Successful";
  }else {
    echo "ERROR";
  }     
} // end of it

this is my button

<input type="submit" name="submit" value="Submit" />

And why would someone want the redundancy of the statement the way I had originally copied it?

 

Are you talking about the "if (isset($_POST['action']) && $_POST['action'] == 'submitform')". ? I don't know, I do this with my sessions but not my submit POST

WOW!  found the same line of code in my UPDATE script.  Took it out and I'm working fine now.

 

Thanks a TON! 

 

(i think i'll quit while ahead... LOL)

 

So what EXACTLY is that line saying?

 

And is it necessary in one way or another as a double-check process of the form?

 

I don't know if it's necessary or not. You haven't posted the form, so my answer was nothing more than a semi-educated guess.

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.