Everything used to work... but that was a long, long, time ago... and there have been many upgrades to PHP and MySQL since I last touched this code and most likely the reason why I am getting errors now. The problem I am seeing is: The code from the lines referenced look like this: $CategoryID[$CategoryCount] = mysql_result($categorysql, 0, "ID"); $CategoryName[$CategoryCount] = mysql_result($categorysql, 0, "Name"); $CategoryBelongs[$CategoryCount] = mysql_result($categorysql, 0, "Belongs"); PHP: Has something changed (within past year or two) with this code ? Or do I need to dig any deeper. I have tried some simple things that my limited PHP knowledge could come up with... such as single quotes instead of the doubles and adding the "or die" thing that I found posted elsewhere. thanks, PS: guess I should mention we are running PHP 5.2.6 and mysql 5.0.51a
I think something wrong with your MySQL query. Can you show us the value of the "$categorysql" variable?
That was found right above the previous code I posted: $categorysql = mysql_query ("SELECT ID, Name, Belongs FROM category WHERE ID = $ArtCategory"); Print mysql_error(); PHP: This (i am guessing) points me to: $ArtCategory = mysql_result($articlesql, 0, 'Category'); PHP: which then leads me to this line of code: $articlesql = mysql_query ("SELECT ID, Category, Author, Email, Title, ArticleBody, ArticleBlurb, DateSub, DateAct, URL, Active FROM articles WHERE ID = $ArticleID AND Active = 1"); $CheckFound = mysql_num_rows($articlesql); If ($CheckFound == 0) PHP: Are we on the right track or have I fallen off yet?
Hm.. Try to use mysql_result() with the first single parametr: mysql_result($articlesql) without "0" and "field name".
It's so strange.. Is there an error like this now? "Warning: mysql_result(): supplied argument is not a valid MySQL result resource" ? Try to test something like this: $ArticleID = intval( $ArticleID ); $articlesql = mysql_query ("SELECT * FROM articles WHERE ID=$ArticleID AND Active=1") or die( mysql_error() ); PHP: Is there any warnings with that code?
That didn't seem to change anything. SO I started digging around this code some more and figured out that this page in question (articles_new.php) is the same one that is working to display the single articles on the site. So that even tho the error messages are pointing to this page... I believe the errant code is from another file. Will dig some more.
Add a debuging statement to print the faulty sql that way you can see which statement and where the error arise. $result = mysql_query($query) or die('Error ,query failed <br>'.$query); Code (markup):
I get nothing but "Error ,query failed" with that line javaongsan. I also found that is the correct page producing the error... and it seems it has to do with the .htaccess file... which has this: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /getarticle/articles_new.php [L,QSA] Code (markup): Without this code... I get "Page Not Found" errors for everything... So I guess I need to figure out how it is working for the single article pages and not the category listings. I am thinking I need to intercept and rewrite the URL for any thing pointing to /category ??? Digging some more...
did you do $query="SELECT ID, Name, Belongs FROM category WHERE ID = $ArtCategory"; or what ever sql statement you use
I am really getting lost in all this javaongsan... but I did manage to get "Array" from what your idea... which I think makes sense... the page errors out because it does not have the needed results from the query. I believe the issue is path related because... I made a copy of the site files in a subfolder and was getting the same errors (not a valid MySQL result) for the single article pages. I needed to change the links and also the line: $var_array = explode("/subfolder",$TheURL); Code (markup): and $GlobalSiteDomain = "/subfolder/"; Code (markup): To reflect the move and this fixed those pages... now only if I can figure out how the category pages are supposed to be displayed. Thanks for both your help. We will keep trying things here.