Well, technically the syntax is correct, but the use of the functions are not. You're basing your while loop on a query... But unless i am misunderstanding your code, you should be basing your while loop on the query results. Assuming the query is running correctly, it will always return true, and so you end up with an infinite loop, hence why the max execution time is being reached.
Edit: after looking at the query more, i am not sure what your code is trying to achieve. If your query is pulling a post_title from the post_name (which should be unique in wordpress), your query should only ever be returning one row, so it wouldn't make any sense to base a while loop off of it.
Last edited by Jarrod1937; 07-12-2010 at 09:32 AM.
See the manpage for mysql_fetch_assoc() for an example of how/when to use the while loop for a DB query.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
I need a while loop because I'm trying to create unique slugs (URL friendly string). If the slug already exists, then an incrementing number can be added to the end of the slug to make it unique.
My previous response was using the SQL COUNT() function to get the count of matches, instead of having to loop through all the results in the PHP code in order to do the same thing: count the matches.
In actuality, though, I suspect I would concatenate the DB row's ID (assuming it's an auto-increment integer) rather than go through these contortions, which might have unforeseen side effects if a record gets deleted. In addition, that would remove the query and related processing, adding some efficiency to the process.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks