RE: mySQL UPDATE
| From: | Bastien Koert | Date: | Thu, 09 Jun 2005 22:17:26 +0000 |
| Subject: | RE: mySQL UPDATE | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-39640@lists.php.net to get a copy of this message | ||
whats the col type of the bible-verse_ref field? If its not a numeric field (ie autonumber key) then perhaps consider adding one, and updating on that key...
Bastien
From: "Ron Piggott" <ron.php@actsministries.org> Reply-To: "Ron Piggott" <ron.php@actsministries.org> To: "PHP DB" <php-db@lists.php.net> CC: "Bastien Koert" <bastien_k@hotmail.com> Subject: mySQL UPDATE Date: Thu, 9 Jun 2005 15:00:14 -0400 I created a PHP based mailing list that sends out a Bible verse and a quotation each day. Today's verses were: Bible verse of the day: Matthew 17:19-21 Then the disciples came to Jesus privately and said, "Why could we not cast it out?" And He said to them, "Because of the littleness of your faith; for truly I say to you, if you have faith as a mustard seed, you shall say to this mountain, 'Move from here to there,' and it shall move; and nothing shall be impossible to you. But this kind does not go out except by prayer and fasting." ( NASB ) Quiet Time Quotation And Reflection Topic of the day: If you hold the gospel up and you become it's shadow do you fit? In both the Bible verse table and the quotation table is a "current verse of the day" column that the UPDATE command is suppose to change from a 0 to a 1 so the associated web page will be able to display and a few other functions will know the current verse of the day. The verses are selected randomly. Both the UPDATE for the Bible verse and the UPDATE for the quotation failed. I know the code works over all. From my estimate the use of " or ' is the reason why the UPDATE didn't work. Let me show you some code: It selects a Bible verse: SELECT * FROM bible ORDER BY RAND() LIMIT 1 Then it puts the text into variables: $bible_verse_ref=mysql_result($result,$i,"bible_verse_ref"); $bible_verse_text=mysql_result($result,$i,"bible_verse_text"); $bible_verse_translation=mysql_result($result,$i,"bible_verse_translation"); Then immediately following this is the UPDATE that didn't work: UPDATEbibleSETcurrent_verse_of_the_day= '1' WHEREbible_verse_refLIKE '$bible_verse_ref' ANDbible_verse_textLIKE '$bible_verse_text' ANDbible_verse_translationLIKE '$bible_verse_translation' ANDcurrent_verse_of_the_dayLIKE '0' LIMIT 1 Where there are no ' or " this piece of code works just fine. I am essentially retrieving a Bible verse from the table and then immediately searching for it to change the 'current_verse_of_the_day' to change from 0 to 1. I have manually made the change for today and the current_verse_of_the_day value was 0. Similar code is used for the quotation --- but there is no need for me to repeat it here. Any ideas how I am able to get the use of ' or " to work on this page? Ron