mysql_result problems after upgrade

Discussion in 'MySQL' started by scoopy82, Mar 19, 2008.

  1. #1
    I have this custom site / script I had purchased from someone... but since upgrading to php5... seems something broke. Some of the pages are working fine with the mySQL database... but others are not. Here's the error I am getting:
    I get 13 of those errors (1@ per use of mysql_result)... The code this is coming from:
    <?php
    $TheURL = $_SERVER['REQUEST_URI'];
    $var_array = explode("/",$TheURL);
    $GotURL = $var_array[1];
    
    $ArticleID = substr($GotURL, 7);
    settype($ArticleID, "integer");
    
    $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)
    {
    	//404 redirect
    	//header("Location: /index.php");
    }
    $ArtID = mysql_result($articlesql, 0, "ID");
    $ArtCategory = mysql_result($articlesql, 0, "Category");
    $ArtAuthor = mysql_result($articlesql, 0, "Author");
    $ArtTitle = mysql_result($articlesql, 0, "Title");
    $ArtBody = mysql_result($articlesql, 0, "ArticleBody");
    $ArtBlurb = mysql_result($articlesql, 0, "ArticleBlurb");
    $ArtDateSub = mysql_result($articlesql, 0, "DateSub");
    $ArtDateAct = mysql_result($articlesql, 0, "DateAct");
    $ArtURL = mysql_result($articlesql, 0, "URL");
    $ArtActive = mysql_result($articlesql, 0, "Active");
    
    	$CategoryCount = 1;
    //Get the first category
    $categorysql = mysql_query ("SELECT ID, Name, Belongs FROM category WHERE ID = $ArtCategory");
    Print mysql_error();
    //Get First Records and put into the array
    $CategoryID[$CategoryCount] = mysql_result($categorysql, 0, "ID");
    $CategoryName[$CategoryCount] = mysql_result($categorysql, 0, "Name");
    $CategoryBelongs[$CategoryCount] = mysql_result($categorysql, 0,"Belongs");
    $CatBelongs = $CategoryBelongs[$CategoryCount];
    //Print "CatID = $CatID, $CategoryID[$CategoryCount]";
    $TheEnd = false;
    
    //Get we have a categories
    If($CatBelongs != 0)
    {
    //Put all the category struture in the array
    While (!$TheEnd)
    {
    	$CategoryCount++;
    	$categorysql = mysql_query ("SELECT ID, Name, Belongs FROM category WHERE ID = $CatBelongs");
    	$CategoryID[$CategoryCount] = mysql_result($categorysql, 0, "ID");
    	$CategoryName[$CategoryCount] = mysql_result($categorysql, 0, "Name");
    	$CategoryBelongs[$CategoryCount] = mysql_result($categorysql, 0, "Belongs");
    	$CatBelongs = $CategoryBelongs[$CategoryCount];
    	If($CatBelongs == 0)
    	{
    		$TheEnd = true;
    	}
    	If($CategoryCount > 10)
    	{
    		$TheEnd = true;
    	}
    	//Print $CategoryName[$CategoryCount] . "&nbsp;>>&nbsp;";
    }
    }
    	
    	$MainKeyword = "$ArtTitle";
    	$MainCategory = $CategoryName[1];
    
    ?>
    PHP:
    Is there a way I can fix this within the above code?

    thanks,
     
    scoopy82, Mar 19, 2008 IP
  2. X.Homer.X

    X.Homer.X Peon

    Messages:
    290
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you have
    
    $ArtID = mysql_result($articlesql, 0, "ID");
    
    Code (markup):
    are you sure that your mysql table has a field with 0 as the ID? because if its auto_increment they start at 1. At least mine do.

    This may not be the problem, but im just wondering what you are recalling, im kind of a newbie to mysql, and dont know all the errors etc. but that just looks kinda fishy to me :p someone care to back me up or contradict me, go right ahead, just stating my opinion :p
     
    X.Homer.X, Mar 19, 2008 IP
  3. scoopy82

    scoopy82 Active Member

    Messages:
    838
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    70
    #3
    Thanks, but I have no clue about this mySQL stuff... but I do know, by using phpMyAdmin, that if I go to export anything... it always fills in a "0" where it says, "starting at record #"
     
    scoopy82, Mar 19, 2008 IP