Hi Can someone please look at the problem,thanks

Discussion in 'PHP' started by alan123, Nov 2, 2009.

  1. #1
    i am setting up a new script,but keep getting the message and begin new to php i have probably over looking some thing,


    Parse error: syntax error, unexpected T_VAR in /home/online/public_html/include/db.inc.php on line 198


    return (@mysql_fetch_array($this->result, MYSQL_NUM));

    }



    function fetchAssoc()

    {


    198 var $database ='online_shop';
    return (@mysql_fetch_assoc($this->result));

    }



    function freeResult()

    {

    return (@mysql_free_result($this->result));

    }

    }

    define('BASEURL','http://www.online-'); //protocol required (http://)

    /*

    define('BASEURLCSSNEW','http://static.css.influxive.info/greenfairnew');

    define('BASEURLICONS','http://wcons.df.influxive.info/greenfairnew');

    define('BASEURLHOWITWORKS','http://oi.how.it.influxive.info/greenfai


    Thanks in advance
     
    alan123, Nov 2, 2009 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Remove the whole line 198 as it's redundant.
     
    nico_swd, Nov 2, 2009 IP
  3. alan123

    alan123 Peon

    Messages:
    140
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi

    Thanks i have just done what you said and now i get this message...

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/online/public_html/include/bit_functions.inc.php on line 4

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/online/public_html/include/functions.php on line 258

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/online/public_html/index.php on line 129

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/online/public_html/index.php on line 141
    mysql_error

    Any further help would be great
     
    alan123, Nov 2, 2009 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Okay, please post your whole code (the whole file).

    And put the code between [php] [/php] wrappers, so it'll be easier to read.
     
    nico_swd, Nov 2, 2009 IP
  5. alan123

    alan123 Peon

    Messages:
    140
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    HI

    <?php



    class DB

    {

    // Connection parameters



    var $host = 'localhost';

    var $user ="moneyau_money2";

    var $password ="panameasi2lei";

    var $persistent = false;

    var $adminid='admin';

    var $adminipwd='admin';









    // Database connection handle

    var $conn = NULL;



    // Query result

    var $result = false;



    // function DB($host, $user, $password, $database, $persistent = false)

    function DB()

    {



    }



    function open()

    {

    // Choose the appropriate connect function

    if ($this->persistent) {

    $func = 'mysql_pconnect';

    } else {

    $func = 'mysql_connect';

    }



    // Connect to the MySQL server

    $this->conn = $func($this->host, $this->user, $this->password);

    if (!$this->conn) {

    return false;

    }



    // Select the requested database

    if (!@mysql_select_db($this->database, $this->conn)) {

    return false;

    }



    return true;

    }





    function close()

    {

    return (@mysql_close($this->conn));

    }



    function error()

    {

    return (mysql_error());

    }



    function query($sql = '')

    {

    $this->result = @mysql_query($sql, $this->conn);

    return ($this->result != false);

    }



    function affectedRows()

    {

    return (@mysql_affected_rows($this->conn));

    }



    function numRows()

    {

    return (@mysql_num_rows($this->result));

    }

    function fieldName($field)

    {

    return (@mysql_field_name($this->result,$field));

    }

    function insertID()

    {

    return (@mysql_insert_id($this->conn));

    }



    function fetchObject()

    {

    return (@mysql_fetch_object($this->result, MYSQL_ASSOC));

    }



    function fetchArray()

    {

    return (@mysql_fetch_array($this->result, MYSQL_NUM));

    }



    function fetchAssoc()

    {


    var $database ='moneyau_money2';
    return (@mysql_fetch_assoc($this->result));

    }



    function freeResult()

    {

    return (@mysql_free_result($this->result));

    }

    }

    define('_BASEURL_','http://www.money-auctions.com'); //protocol required (http://)

    /*

    define('_BASEURLCSSNEW_','http://static.css.influxive.info/greenfairnew');

    define('_BASEURLICONS_','http://wcons.df.influxive.info/greenfairnew');

    define('_BASEURLHOWITWORKS_','http://oi.how.it.influxive.info/greenfairnew');

    define('_BASEURLTEMPLATEIMAGE_','http://ti.ak.img.influxive.info/greenfairnew');

    define('_BASEURLMEDIA_','http://media.fr.influxive.info/greenfairnew');

    define('_BASEURLMEDIAIMAGES_','http://img.zs.ch.influxive.info/greenfairnew');

    */



    define('_BASEURLCSSNEW_','http://www.money-auctions.com/div2');

    define('_BASEURLICONS_','http://www.money-auctions.com/div2');

    define('_BASEURLHOWITWORKS_','http://www.money-auctions.com/div2');

    define('_BASEURLTEMPLATEIMAGE_','http://www.money-auctions.com/div2');

    define('_BASEURLMEDIA_','http://www.money-auctions.com/div2');

    define('_BASEURLMEDIAIMAGES_','http://www.money-auctions.com/div2');



    define('_BASEPATH_','/home/moneyau/public_html');

    define('_IMAGESURL_',_BASEURL_.'/images');

    define('_IMAGESPATH_',_BASEPATH_.'/images');

    define('_IMAGESURLM_',_BASEURL_.'notesimages');

    define('_IMAGESPATHM_',_BASEPATH_.'notesimages');

    define('_ADMIN_MAIL_','info@money-auctions.com');

    define('_TITLE_','Money Auctions | ');

    define('_TITLE1_','Money Auctions ');

    $accepted_upload_extensions_pics = array('gif','jpg','jpeg','png');



    function get_uname($uid){

    $sql="select * from user where id='$uid'";

    $myrwd=mysql_query($sql);

    $myuname=mysql_fetch_array($myrwd);

    $uname=$myuname['uname'];

    return $uname;

    }





    ?>
     
    alan123, Nov 2, 2009 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    Move line 198 below this one:
    
    var $adminipwd='admin';
    
    PHP:
     
    nico_swd, Nov 2, 2009 IP
  7. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #7
    alan123, you broke our eyes :)
    
    <?php
    class DB
    {
    // Connection parameters
    var $host = 'localhost';
    var $user ="moneyau_money2";
    var $password ="panameasi2lei";
    var $persistent = false;
    var $adminid='admin';
    var $adminipwd='admin';
    
    // Database connection handle
    var $conn = NULL;
    
    // Query result
    var $result = false;
    
    
    
    // function DB($host, $user, $password, $database, $persistent = false)
    function DB()
    {
    
    }
    
    function open()
    {
    // Choose the appropriate connect function
    if ($this->persistent) {
      $func = 'mysql_pconnect';
    } else {
      $func = 'mysql_connect';
    }
    
    // Connect to the MySQL server
    $this->conn = $func($this->host, $this->user, $this->password);
    if (!$this->conn) {
      return false;
    }
    
    // Select the requested database
    if (!@mysql_select_db($this->database, $this->conn)) {
      return false;
    }
      return true;
    }
    
    function close()
    {
      return (@mysql_close($this->conn));
    }
    
    function error()
    {
      return (mysql_error());
    }
    
    
    function query($sql = '')
    {
      $this->result = @mysql_query($sql, $this->conn);
      return ($this->result != false);
    }
    
    function affectedRows()
    {
      return (@mysql_affected_rows($this->conn));
    }
    
    function numRows()
    {
      return (@mysql_num_rows($this->result));
    }
    
    function fieldName($field)
    {
      return (@mysql_field_name($this->result,$field));
    }
    
    function insertID()
    {
      return (@mysql_insert_id($this->conn));
    }
    
    function fetchObject()
    {
      return (@mysql_fetch_object($this->result, MYSQL_ASSOC));
    }
    
    function fetchArray()
    {
      return (@mysql_fetch_array($this->result, MYSQL_NUM));
    }
    
    function fetchAssoc()
    {
      var $database ='moneyau_money2';
      return (@mysql_fetch_assoc($this->result));
    }
    
    function freeResult()
    {
      return (@mysql_free_result($this->result));
    }
    }
    
    define('_BASEURL_','http://www.money-auctions.com'); //protocol required (http://)
    define('_BASEURLCSSNEW_','http://www.money-auctions.com/div2');
    define('_BASEURLICONS_','http://www.money-auctions.com/div2');
    define('_BASEURLHOWITWORKS_','http://www.money-auctions.com/div2');
    define('_BASEURLTEMPLATEIMAGE_','http://www.money-auctions.com/div2');
    define('_BASEURLMEDIA_','http://www.money-auctions.com/div2');
    define('_BASEURLMEDIAIMAGES_','http://www.money-auctions.com/div2');
    define('_BASEPATH_','/home/moneyau/public_html');
    define('_IMAGESURL_',_BASEURL_.'/images');
    define('_IMAGESPATH_',_BASEPATH_.'/images');
    define('_IMAGESURLM_',_BASEURL_.'notesimages');
    define('_IMAGESPATHM_',_BASEPATH_.'notesimages');
    define('_ADMIN_MAIL_','info@money-auctions.com');
    define('_TITLE_','Money Auctions | ');
    define('_TITLE1_','Money Auctions ');
    $accepted_upload_extensions_pics = array('gif','jpg','jpeg','png');
    
    
    function get_uname($uid){
      $sql="select * from user where id='$uid'";
      $myrwd=mysql_query($sql);
      $myuname=mysql_fetch_array($myrwd);
      $uname=$myuname['uname'];
      return $uname;
    }
    ?> 
    
    PHP:
    Usually
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
    Code (markup):
    means that you have syntax error in your sql query.
    Try
    
    echo mysql_error();
    
    PHP:
    after line that are mentioned in error messages.
     
    AsHinE, Nov 2, 2009 IP
  8. alan123

    alan123 Peon

    Messages:
    140
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    hi

    And thanks for both of your answers,i have tried both and still nothing changes,do you have any more ideas?

    regards alan
     
    alan123, Nov 2, 2009 IP
  9. nice.wallpapers

    nice.wallpapers Active Member

    Messages:
    142
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #9
    Hi,

    This is very easy solution :

    Just remove var from line 198.

    Correct code will be like this:

    $database ='moneyau_money2';

    Thanks,
    >Harry
     
    nice.wallpapers, Nov 2, 2009 IP
  10. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #10
    This will do the same as removing this line, as the variable is not being used inside the function, and not accessible outside the scope of it.
     
    nico_swd, Nov 2, 2009 IP