Jump to content

DuDeXsNaVe

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

DuDeXsNaVe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the insightful words , you are correct there is no point in what i am trying to do other than learn the syntax for OOP but other than REALLY basic stuff (like get / set) im stuck. Interesting you say im using PHP4 syntax, i had no idea, i am completely self taught and as yet have never read a book on PHP (obviously i will do now, any suggestions for a good one?), just out of curiosity what part of my syntax is PHP4 and what is the PHP5 or even PHP6 equivalent? oh p.s. has anyone actually got an answer to my actual problem, as i would love to know why it is not working!! The 'var' keyword is deprecated, and a clear sign of PHP 4. You should be using one of the access modifiers - 'public', 'protected', or 'private' - instead. PHP 5 has been around since 2004. There's no reason not to get up to speed with it. There is no PHP 6. The key features that were slated for PHP 6 - namespaces and late static binding - have instead been incorporated in the latest version (or so) of PHP 5. Thanks for that, i shall investigate the access modifiers a little more. as i say i am self taught and got the "var" thing from when i used to do VB programming, just found it worked dont think i actually picked it up from anywhere. anyone know of any good books to get upto speed on PHP / PHP OOP as most i have looked at start from a REALLY basic / beginner point of view
  2. I have SOLVED the problem!!!!!!! :D :D but would it be possible for someone to tell me why this worked function querydb($query) { $results = mysql_query($query, $this->con) or die (mysql_error()); return $results; } and this didn't, i dont get the difference function querydb($query) { return mysql_query($query, $this->con) or die (mysql_error()); }
  3. thanks for pointing that out,still no luck though no change
  4. Thanks for the insightful words , you are correct there is no point in what i am trying to do other than learn the syntax for OOP but other than REALLY basic stuff (like get / set) im stuck. Interesting you say im using PHP4 syntax, i had no idea, i am completely self taught and as yet have never read a book on PHP (obviously i will do now, any suggestions for a good one?), just out of curiosity what part of my syntax is PHP4 and what is the PHP5 or even PHP6 equivalent? oh p.s. has anyone actually got an answer to my actual problem, as i would love to know why it is not working!!
  5. nothing blank page, also tested with putting "print_r($result);" into index.php to see what that output was and it just displayed the character "1" nothing else!! really odd, if i purposly enter an incorrect user or password it displays the error as expected so is using the class.
  6. This doesn't really help, it is not telling anything i dont already know.
  7. Hi Folks! I have been designing basic sites / web applications for the last couple of years now but have recently decided that I really want to be able to code amazing sites, so have started a journey to teach myself to become a better programmer / coder. (so any pointers on books to read would be good) my skills so far... (Jquery, PHP (procedural), HTML / XHTML) so want to develop these further and also learn AJAX, PHP OOP. On a daily basis i get on just fine with PHP writing almost all sites / apps in PHP ( Procedural ) but have decided that i should stop being lazy and actually learn to code OOP PHP, the only problem is on my first attemp i am completly stumped, i have wrote what i believe to be an extramly simple piece of code but for some reason it just does not work . Can one of you nice people please point out where the hell i am going wrong, i have written (see code below) a "class_lib.php" for my db connection etc and a simple html ("index.php") to display the results. "CLASS_LIB.PHP" <?php class dbcon { var $dbhost = NULL; var $dbuser = NULL; var $dbpass = NULL; var $db = NULL; var $con = NULL; function setdb($host, $user, $password, $database) { $this->dbhost = $host; $this->dbuser = $user; $this->dbpass = $password; $this->db = $database; $this->con = mysql_connect($this->dbhost,$this->dbuser,$this->dbpass) or die (mysql_error()); mysql_select_db($this->db) or die (mysql_error()); } function querydb($query) { return mysql_query($query, $this->con) or die (mysql_error()); } } ?> "INDEX.PHP" <?php include("class_lib.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p><?php $mysql = new dbcon(); $mysql->setdb('localhost','user','password','database'); $result = $mysql->querydb("SELECT * FROM datatable"); $num=mysql_numrows($result); $i=0; while ($i < $num) { $id = mysql_result($result,$i,"id"); $fname = mysql_result($result,$i,"fname"); $sname = mysql_result($result,$i,"sname"); echo nl2br("<div><b>$fname $sname</b><br /><br /><hr></div>"); $i++; } ?></p> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.