PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm just working through a tutorial from the book php bible second edition. IM having problems with one part of the tutorial.
Below is the code I feel where the problem lies. every time i add data to the form and press enter in order to commit it to the database. I get the message "There was a problem inserting your text" This line is in the code below.
But im confused as to why its getting triggered. I have been trying to work out wgat the code above does and what it means and so far i cant see anything wrong.
would anybody have any ideas as to why i get the error message
Your information is not being inserted. If you have a look in your database you should be able to check this. If you change your code to the following:
My original code works it updates the data in the table but still return the error message. However i tried your code and youir code also upodates the data in the database but still returns with this message
OK i ahve looked up the importance of the zero and its a code that gets generated by using the mysql erno function to help u figure out where the problem is.
$query = "UPDATE mylog SET blogtext = '$blogtext' WHERE date = $edit_date";
// could be...
$query = "UPDATE mylog SET blogtext = '$blogtext' WHERE date = '$edit_date'";
All my rows get effected when i add data regardless of the user.
im learning php at the momment and have bought the php bible second edition it looks like the book has errors in its code becuase i just copied the code out of the book. i was hoping to get it working then try modifying it.
would u be able to suggest a solution to my problem then once its working i can try and modify it
Well...
If the date in your table is just date-field (DDMMYY or similiar) I would change it to reflect a timestamp-field or datetime-field. As you add blogs, you will most likely not have two blogs at the same time anymore.
Then this kind of update would work better.
But, I'd recommend the use of id's instead. Add a field to the database with the name ID, type INT and make it auto_inc and indexed. Everytime a blog is inserted this would increase by one. You can later refer to that instead when updating. ( WHERE ID = '26' ) This makes it impossible to change more than one row.
im learning php at the momment
Then you've come to the right place if you have questions.
Sorry, I can't spot it.
I'm hoping that this is an old test you pasted as it still contains the == 1.
Did you change the datefield in the database to a datetime field? If so, you need to alter the values in those, as just changing the field-type wont help if there is data allready stored within.