Copy link to clipboard
Copied
I have two questions
1)
after using the mysql_query() function you can read the returned data with mysql_result(), mysql_fetch_assoc() or mysql_fetch_array
1a)
I have always used the mysql_result() function myself would I be correct to think that the difference between this and the other two is that the other two do not need to be put into a loop in order to go through the rows of data one at a time?
1b)
What is the difference between mysql_fetch_assoc() and mysql_fetch_array?
2)
The PHP manual says that use of mysql_result(), mysql_fetch_assoc() or mysql_fetch_array is discouraged and that you should use the MySQLi or PDO_MySQL extensions instead
why is this?
Copy link to clipboard
Copied
1a) If the query returns more than one rown then of course you have to loop through them, but not if only one row is returned. Actually I find it odd that you have always used musql_result, which is the most retrictive method. I generally use fetch_assoc.
1b) fetch_assoc returns an associative array, fetch_array returns an indexed array, and mysql_result returns just one cell from a result set.
2) The mysql extension is old. The newer extensions provide much better security and more features. I like the way things are done with PDO; it takes an object oriented approach, but MySQLi is easier to switch to from the original extension. The two extensions offer very similar capabilities. Switch to one or the other as soon as you can.
Copy link to clipboard
Copied
I have started looking at the methods which mysqli provides
i have noticed that it has mysqli_result
is this very different from the old mysql_result method
Copy link to clipboard
Copied
Hi Rob
Apologies for butting in a past conversation but I'm getting pretty desparate here.
I'm a PHP MySQL newbie and I'm using books/Lynda.com to self-train.
So from that layman's standpoint my first major stumbling block is this question of the 'soft deprecation' of the
mysql extension in favour of the the other two.
All my training material advocates the use of msqli.
However I have read that Adobe is unlikely to update this in the near future...if ever.
So when you say switch to one of the improved extensions what exactly do you mean by this?
How can I still use DW with this achilles heel? Or is it the case that I will have to use other software?
As I'm pretty much a beginner on the whole subject I apologise if I'm missing the obvious.
Hope you can shed some light on this as all my research has me floundering in the surf!!
Many Thanks
Regards
Chris
Copy link to clipboard
Copied
m4hs33r wrote:
So when you say switch to one of the improved extensions what exactly do you mean by this?
How can I still use DW with this achilles heel? Or is it the case that I will have to use other software?
You should no longer use the mysql functions. Use mysqli or PDO.
Dreamweaver's built-in PHP server behaviors rely exclusively on the deprecated mysql functions, and are not suitable for deployment in a modern website. You need to hand-code the database connection and queries. Dreamweaver has built-in code hinting and documentation for both mysqli and PDO. It also supports the use of third-party PHP frameworks, such as Symfony and Zend.
If you're just starting out with PHP, do not make the mistake of using Dreamweaver's server behaviors. If you do, it's a decision that you'll quickly come to regret. Anyone with existing sites that use the server behavior code would also be well advised to think about migrating to hand-coded solutions or third-party frameworks. The actual code isn't bad, but it's woefully out of date and will need to be replaced eventually.
Copy link to clipboard
Copied
Hi David
WOW! that was prompt.
I was kind of hoping for a reply roughly along those lines.
So many thanks for that clarity and guidance.
Kind Regards
Chris