[solved]mysql update fail when driven from php
Posted: Tue Dec 07, 2004 6:36 am
history:
first attempt at php code. a group has a uses a friday five on their blogs. this is an attempt to automate the display, picking a question from a mysql db once a week and displaying it.
problem:
i need to update the archive status of the question after it has been picked to avoid repeat showings. when i use the update instruction directly (though not with the array result of course) in mysql it updates.
when i run this script it doesn't. the comments are for my benefit being somewhat green.
the actual retrieval works and displays (a simple include in the index.htm) but always shows the same question because the db isn't updated.
any and all help is greatly appreciated.
first attempt at php code. a group has a uses a friday five on their blogs. this is an attempt to automate the display, picking a question from a mysql db once a week and displaying it.
problem:
i need to update the archive status of the question after it has been picked to avoid repeat showings. when i use the update instruction directly (though not with the array result of course) in mysql it updates.
when i run this script it doesn't. the comments are for my benefit being somewhat green.
the actual retrieval works and displays (a simple include in the index.htm) but always shows the same question because the db isn't updated.
any and all help is greatly appreciated.
Code: Select all
<?php
//this to retrieve a question from the database
//
//connect to the db
require ('f5questions_db_connector.php');
//
//get the data
$retrieve="SELECT * FROM friday_five_machine WHERE archived != 1 ORDER BY date LIMIT 1";
//
//store the SQL query in the result
$result=mysql_query($retrieve) or die(mysql_error());
//
//make it viewable
$result_to_question=mysql_fetch_array($result);
//
//then change the archive state to archived
//
$change_archive_status = "UPDATE friday_five_machine SET archived='1' WHERE counter='$result_to_questionїcounter]' LIMIT 1" ;
//
//display the result
echo "<p>here's the question:<br /><br />$result_to_questionїquestion]<br /><br />";
echo "brought to you by $result_to_questionїname].</p>";
//free up the resource
mysql_free_result($result);
//close the db
mysql_close($connection);
?>