Jump to content

madmindz

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by madmindz

  1. Thanks a million mjdamato your script worked. I changed the primary to id and it worked. I am just not sure why I couldn't keep using heading as the key. Thanks a lot all you guys.
  2. hi frost what did i do wrong? I was just trying to explain myself. I tested each code and trying to explain what happened when i did. I can understand that the fact that you know it makes for a little arrogance but the whole essence of asking a question is to learn the answer. I am not trying to offend dear sir if that is what you are instigating. Why dont we have dialog where instead of telling me how dumb I am why dont you try to help me? (i did say I started a week ago)
  3. GUYS I know you are trying to help me and its annoying to keep asking. Anyway, I am only a week old where php is concerned so if I seem a little confused please bear with me. The last 3 reply to my question didn't help much .The first from gloveny didn't do anything when i inserted it...the second from mjdamato was good but it kept inserting a new record instead of replacing the one thats already there. And the third from mpharo kept giving me a Parse error, unexpected T_VARIABLE in... Ok guys let me explain again what i want to do. The table should contain one record. The query should check to see if there is a record. If there is one then its updated, if not then one is added. The key for that table is heading. Here is the original code again guys. (Oh by the way I did not write this code i am only trying to modify it) :-) thanks. <?php if(isset($_POST['save'])) { $heading = $_POST['heading']; $updates = $_POST['updates']; if(!get_magic_quotes_gpc()) { $heading = addslashes($heading); $updates = addslashes($updates); } $query = " INSERT INTO news (heading, updates) ". " VALUES ('$heading', '$updates')"; mysql_query($query) or die('Error ,query failed'); include 'library/closedb.php'; echo "Update '$heading' added"; } ?>
  4. Thanks guys my primary key is heading and there will be only one entry in that table. Everytime there is a new entry it should replace the older one.
  5. Can anyone help me with this code? here is what I want to do. This block of code works well to insert the data in my table, but what I want it to do is actually update the data that is already there and if no data is there to insert new data. What it keeps doing is adding another row of data instead of replacing the data with the new info. Here is the code. <?php if(isset($_POST['save'])) { $heading = $_POST['heading']; $updates = $_POST['updates']; if(!get_magic_quotes_gpc()) { $heading = addslashes($heading); $updates = addslashes($updates); } $query = " INSERT INTO news (heading, updates) ". " VALUES ('$heading', '$updates')"; mysql_query($query) or die('Error ,query failed'); include 'library/closedb.php'; echo "Update '$heading' added"; } ?>
×
×
  • 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.