garry Posted June 19, 2008 Share Posted June 19, 2008 So I've got two quick questions. I just used the mysql converter tool to change my site to use the mysqli extension for PHP5 and instead of just $result = mysql_query($query) it's changed everything to $result = mysqli_query($GLOBALS["___mysqli_ston"], $query); I was wonder what the $GLOBALS["__mysqli_ston... thing was? Do I need to have that there or is there a way I can get rid of that? And also, I'm wanting to start incorporating classes into my site. I have a vague understanding of how these work but wouldn't mind a real world example. For example, the site I'm making is a music site with reviews, news and interviews. How could I incorporate classes into this? Thanks! Link to comment https://forums.phpfreaks.com/topic/110861-mysqli-and-classes/ Share on other sites More sharing options...
lilwing Posted June 19, 2008 Share Posted June 19, 2008 Not sure about the extension issue... I just use preconfigured wamps/lamps/mamps. But anyway, with classes, I usually put them in a folder called includes, in the root folder of the public part of the website. Check out php.net and look at their docs on classes. It's not very difficult, you just have to figure it out. Anyway, first step is to include the file that the class is in. Then when you want to use the class you declare a variable with a new class, like so: <?php include 'includes/mainclass.php'; $mainclass = new mainclass(); //and then you just do the if clause, or whatever you want. ?> Hope it helps. Link to comment https://forums.phpfreaks.com/topic/110861-mysqli-and-classes/#findComment-568794 Share on other sites More sharing options...
garry Posted June 19, 2008 Author Share Posted June 19, 2008 Thanks for your reply So I understand that bit, but would you be able to give me an example of how I could use classes for my site? Nothing detailed or anything - just an example? This would help me understand it better. And also, using classes is using object oriented programming right? I still need an answer on the first question too if anyone can help Link to comment https://forums.phpfreaks.com/topic/110861-mysqli-and-classes/#findComment-568795 Share on other sites More sharing options...
lilwing Posted June 19, 2008 Share Posted June 19, 2008 Not exactly sure what you are trying to program, or how you are trying to program it. Do you mean like songmeanings.net, where users register and post comments about songs? Check out this example on the PHP.net website. It is an example of a shopping cart for an ecommerce website. You can do pretty much anything, yes it is object-oriented programming. That's what is nice about PHP I use php.net quite often for reference. Just check on there if you want to know how to do something in particular... or post it on here. Try to create a class that does what you are looking for it to do, or explain it a little better. Try starting simple, with functions and variables, and then build up to a class. Link to comment https://forums.phpfreaks.com/topic/110861-mysqli-and-classes/#findComment-568800 Share on other sites More sharing options...
garry Posted June 19, 2008 Author Share Posted June 19, 2008 I already know the basics of php (I already know variables and functions!) and have made a music site. It displays reviews, news and interviews about music and has user accounts and all that sort of stuff. What I wanted to know is what I would use for classes? E.g to get information about a user and display it on a page, can you use classes for that? Or for a form to change a users password, would this be a class? Or am I thinking something completely different Link to comment https://forums.phpfreaks.com/topic/110861-mysqli-and-classes/#findComment-568805 Share on other sites More sharing options...
lilwing Posted June 19, 2008 Share Posted June 19, 2008 Hmm, I am not necessarily sure if you *have* to use classes. I never had to, yet. I just figured classes were designed to tidy up code. For storing usernames and password and profile information... things like that, you should use database programs, like MySQL. To change a user's password, you'd create a form, and then the action would be a php file that updated the password field for that user. Link to comment https://forums.phpfreaks.com/topic/110861-mysqli-and-classes/#findComment-568818 Share on other sites More sharing options...
garry Posted June 19, 2008 Author Share Posted June 19, 2008 Yeah, I already do all that stuff. I was just interested in seeing if I could simplify things by using classes. Link to comment https://forums.phpfreaks.com/topic/110861-mysqli-and-classes/#findComment-568821 Share on other sites More sharing options...
garry Posted June 19, 2008 Author Share Posted June 19, 2008 anyone.? Link to comment https://forums.phpfreaks.com/topic/110861-mysqli-and-classes/#findComment-569018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.