SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pls. help: Warning: Wrong parameter count for mysql_error()

    I'm getting the error: Warning: Wrong parameter count for mysql_error() in the following code at line in bold (first one) and Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource at the line in bold (second occurence).

    Any help please?

    function & getData($sql)
    {
    $this->data_array = array();
    $pageno= $this->pageno;
    $rows_per_page = $this->rows_per_page;
    $this->lastpage = 0;
    if ($pageno == '' || $pageno <= '1')
    $pageno = 1;

    $sql = $sql;
    $result = mysql_query($sql, $this->db) or mysql_error("SQL", E_USER_ERROR);
    if( strtolower($this->paging_require) =="yes")
    {
    if ($rows_per_page > 0)
    $limit_str = "LIMIT " .($pageno - 1) * $rows_per_page ."," .$rows_per_page;
    else
    $limit_str = NULL;
    }

    if($result && mysql_num_rows($result))
    {
    $this->total_rows=mysql_num_rows($result);
    }
    else
    $this->total_rows=0;
    if( strtolower($this->paging_require) =="yes")
    {
    $query_sql ="$sql $limit_str";
    $result=mysql_query($query_sql, $this->db);
    }
    if(mysql_num_rows($result) <= 0)
    {
    $this->pageno =1;
    $this->total_page=1;
    $error_msg=$this->errors;
    return 0;
    }
    else
    {
    if ($rows_per_page > 0 && strtolower($this->paging_require) =="yes")
    $this->total_page = ceil($this->total_rows/$rows_per_page);
    else
    $this->total_page = 1;

    $this->last_page =$this->total_page;
    $query_data = mysql_fetch_row($result);

    if ($pageno > $this->last_page)
    $pageno = $this->last_page;

    $this->pageno = $pageno;
    mysql_data_seek($result, 0);
    while ($row = mysql_fetch_assoc($result))
    {
    $this->data_array[] = $row;
    }
    mysql_free_result($result);

    return $this->data_array;
    }
    }
    Free Programming Help
    SourceCodeHelp.com

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your passing 2 arguments to mysql_error(), but the function can only accept 1 argument.

    www.php.net/mysql_error

  3. #3
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The strange thing is that it works fine on my local machine. When I uploaded this to webhost server, it started giving me this problem.

    Earlier, it used to work on a different webhost as well.

    This is soooo confusing
    Free Programming Help
    SourceCodeHelp.com

  4. #4
    SitePoint Zealot whytewolf's Avatar
    Join Date
    Mar 2006
    Location
    montana
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    um ... take a closer look on your local copy ... cause you have the syntax for trigger_error not mysql_error

  5. #5
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The error was - the table was named as managedata and in php, it was referenced as manageData

    Sometimes, you get strange errors

    It's working fine now after renaming the table.

    Thanks,
    Deep
    Free Programming Help
    SourceCodeHelp.com

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still, your syntax for mysql_error is wrong, and should be fixed.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •