EbolaGumbo wrote:
- MySQL is up and running as I can easily work with it in the MySQL command line client.
- My problem is when I try to make a connection through PHP script.
<?php
// Connect to the database server
$dbcnx = mysql_connect('localhost', 'root', 'viroqua');
if (!$dbcnx) die('Unable to connect to database server at this time');
// Select the jokes database
if (! mysql_select_db('jokes') ) die( 'Unable to locate the joke database at this time.</p>' );
?>
When I run it in my browser I receive the following message:
Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\jokelist2.php on line 11
Yes!
PHP and your choice of database are 2 separate systems, programs.
Located in different parts of your computer hardware. (Drive)
I do not use this data handling setup, and I do not have this problem.
I use my php Mini DB Class and for each website or php application
I make a copy of my Class 12kBytes into a subfolder namned /mdb/ (mini data base)
You can see how it works and the syntax I use, if you click link in lower right corner of this post. It is in my signature.
But if you are too lazy TO CLICK 😃
to see my first nice exmaple of my database class in action,
I show a part of the code here.
Now you can compare, with the above database which is EXTERNAL FROM PHP.
It is not integrated to application script and that DB will NOT Even work,
if your host does not provide SQL.
Wise enough you seem to be your own host web server, like me.
Code to connect to miniDB
<?php
include 'mdb/mdb.conn.php'; // Connect to database
// work with data here. Can be any page.
?>
<?php ///////////// "/mdb/mdb.conn.php"
include 'mdb/mdb.class.php';
include 'mdb/mdb.functions.php';
$mdb=new mdb('dbuser','dbpass');
?>
[right]
Now, as you already were informed here by a nice helper,
your problem is not uncommon and is very easy to solve.
It is a standard problem, using MySQL. And there is a standard answer and solution to it.
You probably have no problem no more and in future.
I just wanted to say, there are other ways
that is less likely to give anyone these connection problems,
when it is hard to know and tell where all different used programs are.
If you do not use any external programs from PHP,
you will have more time to focus on eventual other problems.
YES, IT IS possible to run PHP Totally Independently.
There are so much extension in PHP4 and PHP5 that we need nothing else!
I know this for a fact.
If it werent for Apache and PHP go so good together,
there would most surely have been an HTTP SERVER extension as well ...
🙂[/right]