Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 1st, 2007, 04:50 PM
Registered User
Join Date: Mar 2007
Location: Bernardsville, NJ, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to rretzko
Default Connecting to mySQL with $this->

Hi all - I've been creating procedural code on a WAMP platform for three years. I'm just beginning to learn OOP via PHP5. Here's the problem:
I can connect to mySQL database with the following code:
$connect=mysql_connect('localhost','rick','1 23456');
This works each time, every time.

When I try to OOP code this (via Programmer-to-Programmer Professional PHP5) as:
public function __construct($widgetID) {
$this->connect=mysql_connect('localhost','rick','123456' );
if(! is_resource($this->$hDB)) {
     throw new Exception('Unable to connect to the database.');
I throw an Exception each time every time.

Can anyone help me solve this problem? All suggestions are appreciated!

Thanks - Rick

Reply With Quote
  #2 (permalink)  
Old March 16th, 2007, 12:03 AM
Friend of Wrox
Join Date: Jul 2003
Location: South San Francisco, CA, USA.
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post

Are you using MySQL 5.0?
If you are, you need to change mysql_connect() to mysqli_connect().
How this helps,

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to MYSQL from C / C++ ? oloeriubogdan Linux 1 December 15th, 2006 10:50 AM
Connecting To MySQL from PHP AlisP2P MySQL 1 January 4th, 2006 02:27 AM
Connecting to MySQL Server sleepyd BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 August 4th, 2005 09:13 AM
Connecting to mySQL WIx ASP.NET 1.0 and 1.1 Basics 3 October 17th, 2004 04:13 PM
connecting mysql with vb ks_anoop MySQL 3 February 5th, 2004 02:43 PM

All times are GMT -4. The time now is 05:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.