Parse Error on IF after calling mysql in class
| From: | Lane Fowler | Date: | Tue, 02 May 2000 00:03:14 +0000 |
| Subject: | Parse Error on IF after calling mysql in class | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-14296@lists.php.net to get a copy of this message | ||
I have been beating my head against the monitor for days.
I call mysql from inside a class and will get a Parse error
on the line there is an IF statement.
You can put ANY IF statement at line 55 of the program below
it will always Parse Error!!!
The code works, you have to call the login to setup the variables.
but as I added more code I ran into the problem.
This error is occurring before the program runs, it errors when
the parser is checking the code.
Becauseful if you email program has wrapped some of the lines.
--------------------- Class Sql Error(showthesql)----------------------
<?
# Database class written by
# Lane Fowler
class showthesql {
var $thedata;
var $cursor;
var $ourlogin;
var $ourpass;
var $ourinst; # login stuff
var $dbtype; # what data base are we
var $fieldnames; # field names for record sets latter
var $errorflag; # an error occured
var $maxrows; # number of fiends returned
var $maxcols; # max records
var $eof; # we are at maxcols
var $debugflag; # if set show a little more info
function login($loginname,$passwords,$dbinst,$dbtypename)
{
$this->ourlogin=$loginname;
$this->ourpass=$passwords;
$this->ourinst=$dbinst;
# should check for dbtypes
$this->dbtype=$dbtypename;
} # login
function mysqldo($sqlQuery) {
$this->cursor = 0;
$this->errorflag = false;
$link = mysql_pconnect ($this->ourinst, $this->ourlogin,
$this->ourpass) ;
$sqlx=stripslashes($sqlQuery);
$res = mysql ( $this->ourlogin, $sqlx, $link ) ;
if ($res ) {
$nrows = mysql_num_rows ($res ) ;
$nfields = mysql_num_fields ($res ) ;
$this->maxrows=$nrows; # number of fiends returned
$this->maxcols=$nfields; # max records
$this->eof=false;
printf ( "and it found: <B>%d rows</B>\n",$nrows ) ;
} else {
$this->maxrows=0; # number of fiends returned
$this->maxcols=0; # max records
$this->eof=true;
return ;
}
# This is it! this if statment or any if statment does not work.
# you can change this to any if it will always give you a Parse Error
if (true) then {
}
} # my sql
function maxrows(){
return $this->maxrows;
}
function maxcols() {
return $this->maxcols;
}
} # the class
/*
function login($loginname,$passwords,$dbinst,$dbtypename)
function mysqldo($sqlQuery)
function maxrows()
function maxcols()
*/
?>
____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at http://webmail.netscape.com.