30 users online (0 members and 30 guests)  


  Results 1 to 11 of 11

Related

  1. Need help with MySQL fetch    Forum: Databases
    Replies: 2
  2. mySQL and PHP 1054 error    Forum: Databases
    Replies: 4
  3. Error MySQL Error: 1064 - subqueries    Forum: PHP Forum
    Replies: 0
  4. fetch array problems    Forum: PHP Forum
    Replies: 4
  5. php - fetch array error    Forum: PHP Forum
    Replies: 4
  1. #1
    shyam's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2006
    Posts
    6

    mysql fetch array error please help

    Hello,

    i am getting this errort
    i am new to php & mysql

    XML Parsing Error: junk after document element
    Location: http://www.alfaq.net/articles/articlerss.php
    Line Number 2, Column 1:<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/krisnaa/public_html/articles/articlerss.php</b> on line <b>26</b><br />

  2. #2
    uthus's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Ft Hood
    Posts
    75

    Re: mysql fetch array error please help

    Hi shyam,

    Welcome to the forum.

    How about posting more of the script so we can see what's going on.

    U

  3. #3
    shyam's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2006
    Posts
    6

    Re: mysql fetch array error please help

    i am trying to get rss feed from mysql database
    Code:
    <?header("Content-Type: text/xml");
    include("includes/config.inc"); 
    include("includes/func.php");
    $strxml = "";
    $strxml = $strxml."<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
    $strxml = $strxml."<!DOCTYPE rss >\n";
    $strxml = $strxml."<rss version=\"2.0\">\n";
    $strxml = $strxml."<channel>\n";
    if ($_GET["type"]==1)
    $sql="SELECT A.article_title,A.article_snippet,A.article_id FROM article_master A,category_master C where A.article_category_id=C.category_id and C.category_status=1 and A.article_status=1 order by A.article_views desc";
    if ($_GET["type"]==2 && $_GET["category"]!='')
    $sql="SELECT A.article_title,A.article_snippet,A.article_id FROM article_master A,category_master C where C.category_id=".$_GET["category"]." and A.article_category_id=C.category_id and C.category_status=1 and A.article_status=1 order by A.article_views desc limit 0,100";
    if ($_GET["type"]==3 && $_GET["author_name"]!='') 
    $sql="SELECT C.category_description,C.category_name,A.article_title,A.article_author,A.article_snippet,A.article_category_id,A.article_id,A.article_views FROM article_master A,category_master C where A.article_category_id=C.category_id and C.category_status=1 and A.article_status=1 and A.article_author ='".$_GET["author_name"]."' order by A.article_title asc";
    if ($_GET["type"]==4 && $_GET["q"]!='')
     
    $sql="SELECT C.category_description,C.category_name,A.article_title,A.article_author,A.article_snippet,A.article_category_id,A.article_id,A.article_views FROM article_master A,category_master C where A.article_category_id=C.category_id and C.category_status=1 and A.article_status=1 and (A.article_title like '%".$_GET["q"]."%' OR A.article_snippet like '%".$_GET["q"]."%' OR A.article_summary like '%".$_GET["q"]."%')order by A.article_views desc";
     
    $cmd = mysql_query($sql);
    $strxml = $strxml."<title>".getsettings(2,"",2)." Articles</title>";
    $strxml = $strxml."<link>".getsettings(3,"",2)."/articlerss.php?type=".$_GET["type"]."&amp;category=".$_GET["category"]."</link>";
    $strxml = $strxml."<description>".getsettings(2,"",2)." Articles RSS feeds</description>";
    $strxml = $strxml."<language>en-us</language>";
    $strxml = $strxml."<copyright>Copyright (c) ".getsettings(2,"",2)." All rights reserved.</copyright>";
     
    while ($rs = mysql_fetch_array($cmd))
    {
    $url=getsettings(3,"",2)."/index.php?page=article&amp;article_id=".$rs["article_id"]; 
    $strarray[$j]="<item>\n";
    $strarray[$j]=$strarray[$j]."<title>".htmlentities(strip_tags($rs["article_title"]))."</title>\n";
    $strarray[$j]=$strarray[$j]."<link>".str_replace("&nbsp;", "", strip_tags($url))."</link>\n";
    $strarray[$j]=$strarray[$j]."<description>".htmlentities(strip_tags($rs["article_snippet"]))."</description>\n";
     
    $strarray[$j]=$strarray[$j]."</item>\n";
    $j=$j+1;
    }
     
     
     
     
    for($i=0; $i < $j; $i++)
    {
    $strxml = $strxml.$strarray[$i];
    }
     
    $strxml = $strxml."</channel>\n";
    $strxml = $strxml."</rss>\n";
    print $strxml;
     
     
     
     
     
     
     
    ?>
    Last edited by HTML; 03-17-2007 at 02:23 PM.

  4. #4
    uthus's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Ft Hood
    Posts
    75

    Re: mysql fetch array error please help

    I don't see anything wrong with the script, but after looking at the error message on you page
    Code:
    XML Parsing Error: junk after document element
    Location: http://www.alfaq.net/articles/articlerss.php
    Line Number 2, Column 1:
    <b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/krisnaa/public_html/articles/articlerss.php</b> on line <b>26</b><br />
    ^
    maybe there's something wrong with your includes/config.inc or includes/func.php. Line 2 calls config.inc, so maybe it's there.

    U

  5. #5
    shyam's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2006
    Posts
    6

    Re: mysql fetch array error please help

    below is a copy of config.inc
    Code:
    <?
    global $_cn;
    global $dbserver;
    global $db;
    global $dbuser;
    global $dbpass;
     
    //mysql database server,login,password & Database name
    $dbserver ="localhost";
    $database_connect="krisnaa_articles";
    $dbuser ="krisnaa_articles";
    $dbpass ="***********";
     
    $connect = mysql_connect($dbserver, $dbuser, $dbpass)
    or die("Couldn't connect to MySQL");
    mysql_select_db($database_connect, $connect); 
     
     
    ?>
    Last edited by HTML; 03-17-2007 at 02:24 PM.

  6. #6
    shyam's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2006
    Posts
    6

    Re: mysql fetch array error please help

    below is a copy of func.php
    Code:
    <?php
    function my_magic_quotes($var) {
    foreach ($var AS $key => $value) {
    if (is_array($value))
    $var[$key] = my_magic_quotes($value);
    else
    $var[$key] = addslashes($value);
    }
    return $var;
    }
     
    function redirect($strUrl) {
    if (!empty($strUrl)) {
    closedb();
    header("Location:" . $strUrl);
    //echo $strUrl;
    exit;
    }
    }
    function closedb() {
    global $connect;
    mysql_close($connect);
    }
     
    function setErr($strErrMsg) {
    $_SESSION["errorMessage"] = $strErrMsg;
    }
     
    function getErr($intColspan) {
    if (!empty($_SESSION["errorMessage"])) {
    echo("<tr><td align=\"center\" colspan=\"" . $intColspan ."\" class=\"err\">" . $_SESSION["errorMessage"] . "</td></tr>");
    $_SESSION["errorMessage"] = "";
    }
    }
     
    function showErr() {
    echo($_SESSION["errorMessage"]);
    $_SESSION["errorMessage"] = "";
    }
    function setusererr($strErrMsg) {
    $_SESSION["setusererr"] = $strErrMsg;
    }
    function showusererr() {
    echo("<br><font color=red size=2><B>".$_SESSION["setusererr"]);
    $_SESSION["setusererr"] = "";
    }
    function gotoerror($strErrMsg) {
    setErr($strErrMsg);
    redirect("error.php");
    }
     
    function selfx($strComp1, $strComp2) {
    if (!strcasecmp($strComp1, $strComp2))
    return(" selected");
    }
     
    function chkfx($strChkValue) {
    if (trim($strChkValue) != "")
    return (1);
    else
    return (0);
    }
     
    function cbfx($strCbValue) {
    if (trim($strCbValue) == "1")
    echo(" checked");
    elseif (trim($strCbValue) == "true")
    echo(" checked");
    elseif (trim($strCbValue) == "True")
    echo(" checked");
    }
     
     
    function getfx($key) {
    if (get_magic_quotes_gpc())
    return stripslashes($_GET[$key]);
    else
    return $_GET[$key];
    }
     
    function postfx($key) {
    if (get_magic_quotes_gpc())
    return stripslashes($_POST[$key]);
    else
    return $_POST[$key];
    }
     
    function dbfx($strVal) {
    return addslashes(trim($strVal));
    }
     
    function pdbfx($strVal) {
    if (get_magic_quotes_gpc())
    return trim($_POST[$strVal]);
    else
    return addslashes(trim($_POST[$strVal]));
    }
     
    function gdbfx($strVal) {
    if (get_magic_quotes_gpc())
    return trim($_GET[$strVal]);
    else
    return addslashes(trim($_GET[$strVal]));
    }
     
     
    function stsfx($strStatusValue) {
    //echo $strStatusValue;
    //die;
    if (trim($strStatusValue) == 1)
    echo("<img src=\"../images/icons/+.gif\" border=\"0\">");
    elseif (trim($strStatusValue) == 2)
    echo("<img src=\"../images/icons/+.gif\" border=\"0\">");
    else
    echo("<img src=\"../images/icons/-.gif\" border=\"0\">");
    }
    function stsfxroot($strStatusValue) {
    //echo $strStatusValue;
    //die;
    if (trim($strStatusValue) == 1)
    echo("<img src=\"images/icons/+.gif\" border=\"0\">");
    elseif (trim($strStatusValue) == 2)
    echo("<img src=\"images/icons/+.gif\" border=\"0\">");
    else
    echo("<img src=\"images/icons/-.gif\" border=\"0\">");
    }
    function stsfx2($strStatusValue) {
    //echo $strStatusValue;
    //die;
    if (trim($strStatusValue) == 1)
    echo("<img src=\"images/icons/+.gif\" border=\"0\">");
    elseif (trim($strStatusValue) == 2)
    echo("<img src=\"images/icons/+.gif\" border=\"0\">");
    else
    echo("<img src=\"images/icons/-.gif\" border=\"0\">");
    }
    function stsfx1($strStatusValue, $strTrue) {
    if (cmpfx($strStatusValue, $strTrue))
    echo("<img src=\"../images/icons/-.gif\" border=\"0\">");
    else
    echo("<img src=\"../images/icons/+.gif\" border=\"0\">");
    }
     
    function cmpfx($str1, $str2) {
    if (!strcasecmp($str1, $str2))
    return (1);
    else
    return (0);
    }
     
    function sendmail($strTo, $strFrom, $strCC, $strBCC, $strSubject, $strBody, $htmlMail) {
    $strHeaders = "";
     
    if ($htmlMail) {
    $strHeaders .= "MIME-Version: 1.0\r\n";
    $strHeaders .= "Content-type: text/html; charset=iso-8859-1\r\n";
    }
     
    if (strcmp($strTo, "") != 0)
    $strHeaders .= "To: " . $strTo . "\r\n";
     
    if (strcmp($strFrom, "") != 0)
    $strHeaders .= "From: " . $strFrom . "\r\n";
     
    if (strcmp($strCC, "") != 0) {
    $strHeaders .= "Cc: " . $strCC . "\r\n";
    if (strcmp($strTo, "") != 0)
    $strTo .= "," . $strCC;
    else
    $strTo .= $strCC;
    }
     
    if (strcmp($strBCC, "") != 0) {
    $strHeaders .= "Bcc: " . $strBCC . "\r\n";
    if (strcmp($strBcc, "") != 0)
    $strTo .= "," . $strBcc;
    else
    $strTo .= $strBcc;
    }
     
    return @mail($strTo, $strSubject, $strBody, $strHeaders);
    }
     
    function clearsql() {
    global $_where;
    $_where = "";
    }
     
    function appsql($strCond) {
    global $_where;
    if (!empty($strCond) && strcmp($strCond, "") != 0) {
    if (!empty($_where) && strcmp($_where, "") != 0)
    $_where .= " AND " . $strCond;
    else
    $_where = " WHERE " . $strCond;
    }
    }
     
    function getsql() {
    global $_where;
    return ($_where);
    }
     
    function iff($prmStr, $strTrue, $strFalse) {
    if ($prmStr)
    return $strTrue;
    else
    return $strFalse;
    }
     
    function cint($str) {
    return (round($str, 0));
    }
     
    function cdbl($str) {
    return (round($str, 2));
    }
     
     
    class paging {
    var $ps; //Pagesize
    var $pss; //Page scroll size
     
    var $pg; //Current page
    var $tr; //Total rows
    var $tp; //Total pages
    var $rec; //Start row for limit
    var $cps;
     
    var $sp; //Start page
    var $ep; //End page
     
    var $tps; //Total page sets
    var $pps; //Previous page set
    var $nps; //Next page set
     
    var $i; //Counter
     
    function paging() {
    $this->pss = 5;
     
    if (!empty($_GET["ps"]))
    $this->ps = (int) $_GET["ps"];
    else
    $this->ps = 10;
     
    if (empty($this->ps))
    $this->ps = 10;
     
    if (!empty($_GET["pg"]))
    $this->pg = (int) $_GET["pg"];
    else
    $this->pg = 1;
     
    if (empty($this->pg))
    $this->pg = 1;
     
    $this->i = 1;
    }
     
    function setpages($sql) {
    $rs = mysql_fetch_row(mysql_query($sql));
    $this->tr = $rs[0];
     
    //$this->tp = round($this->tr/$this->ps, 0)+1;
    $this->tp = round($this->tr/$this->ps, 0);
     
    if ($this->tp < 1) $this->tp = 1;
     
    if ($this->tr > $this->ps)
    if (($this->tr%$this->ps) != 0)
    $this->tp++;
    //echo $this->tr%$this->ps;
    if (!empty($this->pg)) {
    if ($this->pg > $this->tp)
    $this->pg = $this->tp;
    }
    else
    $this->pg = 1;
     
    $this->rec = ($this->pg*$this->ps)-$this->ps;
    }
     
    function getlimit() {
    return " limit " . $this->rec . ", " . $this->ps;
    }
    function showPagingw($url, $qs) {
    $this->cps = cint( ($this->pg / $this->pss) + .49 );
    $this->tps = ((cint( ($this->tp / $this->pss) + .49 )-1)*$this->pss)+1;
    $this->sp = (($this->cps-1)*$this->pss)+1;
    $this->ep = $this->sp + 5;
     
    if ($this->ep > $this->tp)
    $this->ep = $this->tp;
     
    $this->pps = $this->sp - 5;
    $this->nps = $this->sp + 5;
     
    echo "<span class=\"paging\">";
     
    //if ($this->pg == 1)
    //echo "&lt;&lt; &lt;";
    //else {
    //if ($this->pps > 0)
    // echo "<a href=\"" . $url . "?pg=" . ($this->pps+4) . "&" . $qs . "\" class=botlinks>&lt;&lt;</a>";
    //else
    // echo "&lt;&lt;";
    //echo "&nbsp;<a href=\"" . $url . "?pg=" . ($this->pg-1) . "&" . $qs . "\" //class=botlinks>&lt;</a>";
    //}
     
    echo " &nbsp; ";
    //$this->ep=($this->ep;
    for ($this->i=$this->sp; $this->i<=$this->ep; $this->i++) {
    if ($this->i == $this->pg)
    echo "[" . $this->i . "]";
    else
    echo "<a href=\"" . $url . "?pg=" . $this->i . "&" . $qs . "\" class=botlinks>" . $this->i . "</a>";
    echo "&nbsp;";
    }
     
    echo " &nbsp; ";
     
    //if ($this->pg == $this->tp)
    //echo "&gt; &gt;&gt;";
    //else {
    //echo "<a href=\"" . $url . "?pg=" . ($this->pg+1) . "&" . $qs . "\" class=botlinks>&gt;</a> ";
    //if ($this->nps <= $this->tps)
    // echo "<a href=\"" . $url . "?pg=" . $this->nps . "&" . $qs . "\" class=botlinks>&gt;&gt;</a>";
    //else
    // echo "&gt;&gt;";
    //}
    }
    function showPaging($url, $qs) {
    $this->cps = cint( ($this->pg / $this->pss) + .49 );
    $this->tps = ((cint( ($this->tp / $this->pss) + .49 )-1)*$this->pss)+1;
    $this->sp = (($this->cps-1)*$this->pss)+1;
    $this->ep = $this->sp + 5;
     
    if ($this->ep > $this->tp)
    $this->ep = $this->tp;
     
    $this->pps = $this->sp - 5;
    $this->nps = $this->sp + 5;
     
    if ($this->pg !=1 && $this->pg!='' )
    echo "<a href='".$url."?pg=".($this->pg-1).$qs."'></a>";
    //echo "Page: ";
     
     
     
    echo " &nbsp; ";
     
    for ($this->i=$this->sp; $this->i<=$this->ep; $this->i++) {
    //$url="Listing".$this->i.".html";
    $url1=$url."?pg=".$this->i.$qs;
    if ($this->i == $this->pg)
    {
    echo "[" . $this->i . "]";
    $nextpage= $url."?pg=".($this->i+1).$qs;
    //echo $nextpage;
    }
    else
     
    echo "<a href=\"" . $url1 . "\" class=bodylinks><strong>" . $this->i . "</strong></a>";
    echo "&nbsp;";
    $url1='';
    }
     
     
    echo " &nbsp; ";
     
     
    }
    }
     
    function alert($str) {
    echo "<script language=\"javascript\" type=\"text/javascript\">" . chr(13);
    echo " alert(\"" . $str . "\");" . chr(13);
    echo "</script>";
    }
     
     
    function getqs($nm) {
    $strqs = "";
    foreach ($_GET as $key=>$val) {
    if (!strpos("," . $nm . ",", $key))
    if ($strqs == "") {
    if (is_array($val))
    $strqs = $key . "[]=" . implode("&" . $key . "[]=", $val);
    else
    $strqs = $key . "=" . $val;
    }
    else {
    if (is_array($val))
    $strqs .= "&" . $key . "[]=" . implode("&" . $key . "[]=", $val);
    else
    $strqs .= "&" . $key . "=" . $val;
    }
    }
    return $strqs;
    }
    function datediff($interval, $datefrom, $dateto, $using_timestamps = false) {
    /*
    $interval can be:
    yyyy - Number of full years
    q - Number of full quarters
    m - Number of full months
    y - Difference between day numbers
    (eg 1st Jan 2004 is "1", the first day. 2nd Feb 2003 is "33". The datediff is "-32".)
    d - Number of full days
    w - Number of full weekdays
    ww - Number of full weeks
    h - Number of full hours
    n - Number of full minutes
    s - Number of full seconds (default)
    */
     
    if (!$using_timestamps) {
    $datefrom = strtotime($datefrom, 0);
    $dateto = strtotime($dateto, 0);
    }
    $difference = $dateto - $datefrom; // Difference in seconds
     
    switch($interval) {
     
    case 'yyyy': // Number of full years
     
    $years_difference = floor($difference / 31536000);
    if (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom), date("j", $datefrom), date("Y", $datefrom)+$years_difference) > $dateto) {
    $years_difference--;
    }
    if (mktime(date("H", $dateto), date("i", $dateto), date("s", $dateto), date("n", $dateto), date("j", $dateto), date("Y", $dateto)-($years_difference+1)) > $datefrom) {
    $years_difference++;
    }
    $datediff = $years_difference;
    break;
     
    case "q": // Number of full quarters
     
    $quarters_difference = floor($difference / 8035200);
    while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($quarters_difference*3), date("j", $dateto), date("Y", $datefrom)) < $dateto) {
    $months_difference++;
    }
    $quarters_difference--;
    $datediff = $quarters_difference;
    break;
     
    case "m": // Number of full months
     
    $months_difference = floor($difference / 2678400);
    while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($months_difference), date("j", $dateto), date("Y", $datefrom)) < $dateto) {
    $months_difference++;
    }
    $months_difference--;
    $datediff = $months_difference;
    break;
     
    case 'y': // Difference between day numbers
     
    $datediff = date("z", $dateto) - date("z", $datefrom);
    break;
     
    case "d": // Number of full days
     
    $datediff = floor($difference / 86400);
    break;
     
    case "w": // Number of full weekdays
     
    $days_difference = floor($difference / 86400);
    $weeks_difference = floor($days_difference / 7); // Complete weeks
    $first_day = date("w", $datefrom);
    $days_remainder = floor($days_difference % 7);
    $odd_days = $first_day + $days_remainder; // Do we have a Saturday or Sunday in the remainder?
    if ($odd_days > 7) { // Sunday
    $days_remainder--;
    }
    if ($odd_days > 6) { // Saturday
    $days_remainder--;
    }
    $datediff = ($weeks_difference * 5) + $days_remainder;
    break;
     
    case "ww": // Number of full weeks
     
    $datediff = floor($difference / 604800);
    break;
     
    case "h": // Number of full hours
     
    $datediff = floor($difference / 3600);
    break;
     
    case "n": // Number of full minutes
     
    $datediff = floor($difference / 60);
    break;
     
    default: // Number of full seconds (default)
     
    $datediff = $difference;
    break;
    } 
     
    return $datediff;
     
    }
     
    function str_contains($haystack, $needle, $ignoreCase = false) {
    if ($ignoreCase) {
    $haystack = strtolower($haystack);
    $needle = strtolower($needle);
    }
    $needlePos = strpos($haystack, $needle);
    return ($needlePos === false ? false : ($needlePos+1));
    }
    function genpasswordalpha($length){ 
     
    srand((double)microtime()*1000000); 
     
    $vowels = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "p","q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); 
    $cons = array("1", "2", "3", "4", "5", "6", "7", "8", "9"); 
     
    $num_vowels = count($vowels); 
    $num_cons = count($cons); 
     
    for($i = 0; $i < $length; $i++){ 
    $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)]; 
    } 
     
    return strtoupper(substr($password, 0, $length)); 
    } 
    function genpasswordnum($length){ 
     
    srand((double)microtime()*1000000); 
     
    $vowels = array("1", "2", "3", "4", "5", "6", "7", "8", "9"); 
    $cons = array("1", "2", "3", "4", "5", "6", "7", "8", "9"); 
     
    $num_vowels = count($vowels); 
    $num_cons = count($cons); 
     
    for($i = 0; $i < $length; $i++){ 
    $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)]; 
    } 
     
    return substr($password, 0, $length); 
    } 
    function GetRecortarTexto ($vTxt, $Car) {
    if (strlen($vTxt) > $Car) {
    return substr($vTxt, 0, $Car) . "...";
    } else return $vTxt;
    }
     
    function GetIP()
    {
    if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
    $ip = getenv("HTTP_CLIENT_IP");
    else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
    $ip = getenv("HTTP_X_FORWARDED_FOR");
    else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
    $ip = getenv("REMOTE_ADDR");
    else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
    $ip = $_SERVER['REMOTE_ADDR'];
    else
    $ip = "unknown";
    //$ip=str_replace(".","-",$ip);
    //$ip2=split("-",$ip);
     
    //$ip1=str_replace("-".$ip2[3],"-XXX",$ip);
    //$ip1=str_replace("-",".",$ip1);
    return($ip);
    }/*-------GetIP()-------*/
    function PrepareName($s)
    {
    $abc = "1234567890abcdefghijklmnopqrstuvwxyz";
    $s = strtolower($s);
    $r = "";
    for($i=0;$i<strlen($s);$i++)
    {
    if (strpos($abc,$s[$i])!==false)
    $r .= $s[$i];
    if (($s[$i]==' ')&&($r[strlen($r)-1]!=' '))
    $r .= ' ';
    } 
    $r = trim($r);
    return str_replace(' ','-',$r);
    }
     
    function getsettings($variable_id,$selected,$returntype=1,$default=1,$multiple=1) {
     
    $sql="select * from settings where variable_id=".$variable_id;
    $cmd = mysql_query($sql);
    mysql_query($sql);
    while ($rs = mysql_fetch_array($cmd)) 
    {
    if ($returntype==1)
    {
    $temp=split(",",$rs[1]);
    if ($default==2)
    if ($multiple==2 && $selected=='')
    echo "<option value='' selected>----Any----</option>";
    else
    echo "<option value=''>----Any----</option>";
    for($i=0;$i<count($temp);$i++)
    {
    if ($temp[$i]==$selected)
    echo "<option value='".$temp[$i]."' selected>".$temp[$i]."</option>";
    else 
    if ($multiple==2 && str_contains($selected,$temp[$i]))
    echo "<option value='".$temp[$i]."' selected>".$temp[$i]."</option>";
    else
    echo "<option value='".$temp[$i]."'>".$temp[$i]."</option>";
    }
    }
    else
    return $rs[1];
     
    } 
     
     
    }
    function getsettingssingle($variable_id) {
     
    $sql="select * from settings where variable_id=".$variable_id;
    $cmd = mysql_query($sql);
    mysql_query($sql);
    while ($rs = mysql_fetch_array($cmd)) 
    {
    return $rs[1];
     
    } 
     
     
    }
    function categorypath($cat)
    {
    $ret="";
     
    while($cat>0)
    {
    $sql="select category_id,category_name,category_parent_id from category_master where category_id=$cat ";
    $cmd = mysql_query($sql);
     
    $rs = mysql_fetch_array($cmd);
    if($rs!=0)
    {
    $catnameis = $rs[1];
    $catnameis = str_replace("/","-",$catnameis);
    $catnameis = str_replace(" ","-",$catnameis);
    $catnameis = str_replace("?","-",$catnameis);
    $catnameis = str_replace(":","-",$catnameis);
     
    $ret=($cat==1?"":"  ").$catnameis.$ret;
    $cat=$rs[2];
    }
    else
    $cat=0;
    }
    return $ret;
    }
     
    function categorypathlink($cat,$default=0)
    {
    $ret="";
     
    while($cat>0)
    {
    $sql="select category_id,category_name,category_parent_id from category_master where category_id=$cat";
    $cmd = mysql_query($sql);
     
    $rs = mysql_fetch_array($cmd);
    if($rs!=0)
    {
    $catnameis = $rs[1];
    $catnameis = str_replace("/","-",$catnameis);
    $catnameis = str_replace(" ","-",$catnameis);
    $catnameis = str_replace("?","-",$catnameis);
    $catnameis = str_replace(":","-",$catnameis);
     
     
    if ($cat!=1)
    if ($default!=$cat)
    $ret=($cat==1?"":"  ")."<a href='category".$rs[0].".html' class=bodylinks>".$catnameis."</a>".$ret;
    else
    $ret=($cat==1?"":"  ").$catnameis.$ret;
    else
    $ret=($cat==1?"":"  ")."<a href='index.php' class=bodylinks>".$catnameis."</a>".$ret;
    $cat=$rs[2];
    }
    else
    $cat=0;
    }
    return $ret;
    }
     
    function DateAdd($v,$d=null , $f="Y-m-d"){ 
    $d=($d?$d:date("Y-m-d")); 
    return date($f,strtotime($v." days",strtotime($d))); 
    }
    function DateMinus($v,$d=null , $f="Y-m-d"){ 
    $d=($d?$d:date("Y-m-d")); 
    return date($f,strtotime(-$v." days",strtotime($d))); 
    }
     
    function generateCategories($cat,$lev,$default)
    {
    if ($cat!=1)
    echo "<option value=$cat ".(isset($default)&&$default==$cat?"selected":"").">";
    for($x=0;$x<$lev;$x++)
    echo "- ";
    $result=mysql_query("select category_name from category_master where category_id=$cat");
    $rscat = mysql_fetch_array($result);
    echo $rscat["category_name"];
    $result=mysql_query("select category_id from category_master where category_parent_id=$cat order by category_name");
    while ($rscat = mysql_fetch_array($result))
    {
     
    generateCategories($rscat["category_id"],$lev+1,$default);
    }
     
    mysql_free_result($result);
    }
    function generateCategoriesroot($cat,$lev,$default)
    {
     
    echo "<option value=$cat ".(isset($default)&&$default==$cat?"selected":"").">";
    for($x=0;$x<$lev;$x++)
    echo "- ";
    $result=mysql_query("select category_name from category_master where category_id=$cat");
    $rscat = mysql_fetch_array($result);
    echo $rscat["category_name"];
    $result=mysql_query("select category_id from category_master where category_parent_id=$cat order by category_name");
    while ($rscat = mysql_fetch_array($result))
    {
     
    generateCategories($rscat["category_id"],$lev+1,$default);
    }
     
    mysql_free_result($result);
    }
    function makeClickableLinks($text) { 
    $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','<a href="\\1" target=_blank>\\1</a>', $text); 
    $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1<a href="http://\\2" target=_blank>\\2</a>', $text); 
    $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1">\\1</a>', $text); 
    return $text;
    }
    ?>
    Last edited by HTML; 03-17-2007 at 02:24 PM.

  7. #7
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: mysql fetch array error please help

    Please use the [ code ] tags.

  8. #8
    uthus's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Ft Hood
    Posts
    75

    Re: mysql fetch array error please help

    Hi,

    I haven't been able to play around with your scripts yet, but I'm at a place where I've got time now. I'll see in the next couple of days what I can do.

    U

  9. #9
    uthus's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Ft Hood
    Posts
    75

    Re: mysql fetch array error please help

    Hi,

    Sorry it's taken me so long to get back to this... I can't find anything wrong with what you've got. I do see that you've got that error to go away, though.

    U

  10. #10
    shyam's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2006
    Posts
    6

    Re: mysql fetch array error please help

    Quote Originally Posted by uthus
    Hi,

    Sorry it's taken me so long to get back to this... I can't find anything wrong with what you've got. I do see that you've got that error to go away, though.

    U
    the error has not gone. i read it on a forum that add "@" before your mysql_fetch_array what does "@" do

    Code:
    while ($rs = @mysql_fetch_array($cmd))
    but it does not read my database can you tell me how i can query my database i am a newbie things are difficult for me

  11. #11
    shyam's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2006
    Posts
    6

    Re: mysql fetch array error please help

    this file is also using mysql_fetch_array but it is working properly

    http://www.alfaq.net/articles/admin/daily.php

    Code:
    <?php include("../includes/config.inc"); 
    include("../includes/func.php");?>
    <?php
    
    $sql="SELECT A.*,C.category_name from article_master A ,category_master C where A.article_category_id=C.category_id and  A.article_email=0 and A.article_status=1 order by 1 desc";
    $cmd = mysql_query($sql);
    while ($rs = mysql_fetch_array($cmd)) {
        $i=$i+1;
        $str.="<a href='".getsettingssingle(3)."/article".$rs["article_id"].".html'>".$rs["article_title"]."</a><br>(".$rs["category_name"].")<br><br>";
    }
    if ($str!='')
    {
        $subject="Daily Article Digest from ".getsettingssingle(2);
        $str=str_replace("XXXLINKXXX",$str,getsettingssingle(4));
        $str=str_replace("XXXWEBSITEXXX",getsettingssingle(2),$str);
        $str=str_replace("XXXNUMBERXXX",$i,$str);
        $sql="SELECT * from user_master where user_daily_email=1 order by 1 desc";
        $cmd = mysql_query($sql);
        while ($rs = mysql_fetch_array($cmd)) {
            $tempstr=str_replace("XXXNAMEXXX",$rs["first_name"],$str);
            $headers = "From: ".getsettingssingle(1)." \nContent-Type: text/html";
            mail($rs["email"],$subject,$tempstr,$headers);
            echo "<br>Email sent to ".$rs["email"];
            
        }
    }
    $sql="update article_master set article_email=1";
    mysql_query($sql);
    include("category_counter.php");
    closedb();
    ?>



Tags for this Thread