result question on id that does not exist
Hi, i am working on my error control, and as a test i ran a url that simulated a delete action on a row id that
did not exist to make sure my error message is triggered properly.
The value of result is 1 which i assume means true.
Question, how can result be true when the ID i submitted does not exist?
I wonder if mysqli_affected_rows would be a better choice.
This does seem to work
I know it's kind of a strange and apparenly out-of-date idea, buy you might try reading the PHP manual:
I quote (in part):
Hi yes i did read the manual that is where i got the idea for using the affected rows from in the first place because i have not used it before.
My question came from the fact that i did not realize that on a delete specifically that when an id is not found it does nothing but result true, i thought i would give some notice that the record was not found and i have always coded for that fact using result.
Now i know that some of my statement from the past will always be true, i just did not realize that on a delete it would always be true even if the record did not exist.
I do appreciate your help but i also somewhat resent the implication that i did not refer to the manual first, it was just a misunderstanding.
Sorry! I saw your post before you added the UPDATE. But then it was still sitting on my browser screen and I didn't refresh before answering.
You clearly did read the manual, and I apologize.
You would know that SQL (any kind of SQL, be it MySQL, SQL Server, Oracle, or even Access) does not *EVER* consider it an error (or even a warning) when there are no rows affected by a DELETE or UPDATE (or SELECT! think about it!) if you had experience doing ad hoc queries directly to the database.
In a way, I think it's too bad that people don't learn the command line client nowadays. It really gives you the closest interaction with MySQL and the best feeling for how things work, in my opinion. But I do understand the attraction of tools such as phpMySqlAdmin (or whatever the right name is).
Groovy, yeah maybe when i get my own ded server i can play with that but for not it is phpMyAdmin.
Its all good and again thanks :) :thumbsup:
??? You don't run MySQL on your desktop machine? Why not?
Then you can do all your development and debugging locally before uploading to the server.
Man, I could not *LIVE* with having to do work directly on the production server! (Well, I could, and I have, but it's at least 3 times more difficult.)
lol i guess i just never thought about it, i have always done my development on a live server environment in my own test env section, this way i know without a doubt it will work as i stated.
I never (not even in the old days of databus and fortran or JCL ) wanted to have to take my work home with me so i guess over the years i just developed everything on a live environment. I never really believed in many of the localized api or mini dev packages that were available and so i just always do everything on live env.
I guess the one reason i can get away with it is i do alot of work on one particular software (other than my personal stuff) and i also run the same copy in my dev library so its not like im having to upload anything new.
Just as you would have a hard time doing it my way, i would have a hard time doing it your way lol...
Just wanted to clarify though it may be a live env but it is not a public env, doing work on a live site while users are using it is not my cup of tea, although in a crunch i have done it, we all have.
Well, that's some comfort at least (the non-live dev environment).
But I just hate the tedium of upload and test, upload and test.
Of course, I do a lot of work in ASP.NET, and MS's Visual Studio gives you a debug environment that is wonderful: You can hardly tell the difference between debugging server-side and client-side code. I can set breakpoints either place and inspect variable values either place and ... (Well, granted, you are stuck using MSIE as a browser during debug, but that just means I need to make a quick run-through with FF and Chrome after things are debugged, to make sure it all works in them as well.)
Even if you crash, you won't take down your main browser, as VS creates a custom development browser for you (still IE, of course).
|All times are GMT +1. The time now is 07:53 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.