|
Posted by Jerry Stuckle on 08/02/05 06:33
MBS wrote:
> Jerry Stuckle <jstucklex@attglobal.net> wrote in
> news:366dnSotJcfVU3PfRVn-1Q@comcast.com:
>
>
>>MBS wrote:
>>
>>>Yeah, read the previous posts...I did that. None answer my question.
>>>
>>>I just installed PHP 5.0.4, Apache 2.0.54, and MySQL 4.1.13 a few
>>>days ago on WinXP SP2. My goal is to learn to use these programs.
>>>
>>>I cannot, absolutely cannot connect to MySQL using PHP. I've tried
>>>everything possible including the mysqli functions.
>>>
>>>I have no idea what is wrong. I don't get any error messages at all.
>>> It's almost as if PHP stops processing the php file in mid stream.
>>>
>>>PHP is installed properly (I followed the installation instructions
>>>to the letter). Simple php files process OK. MySQL is installed
>>>fine--I've loaded data from an Access table and have been querying it
>>>fine using the MySQL Query Browser. But I cannot connect to MySQL
>>>using PHP!
>>>
>>>Is there anyone out there that can help me?
>>>
>>>I am thinking that someone could create a simple DB with one table in
>>>it with a little bit of text in one of the fields (as a test), then
>>>write some PHP code that they KNOW works. Then I'll set up a DB the
>>>same and run that PHP code and see if it works on my system.
>>>
>>>Shouldn't take someone more than two or three minutes to do this. If
>>>they are willing to help...
>>>
>>>I've been working on this for about 3 hours now to no avail. I'm
>>>about ready to give up on this open source stuff. But I really do
>>>want to learn this. I just need help getting over this one little
>>>hurdle.
>>>
>>>Thanks.
>>>
>>
>>How about showing us the code you're using?
>>
>>
>
>
> OK. But it's from a book and copyrighted. That's why I didn't provide it
> originally. But here goes:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <title>Our List of Jokes</title>
> <meta http-equiv="content-type"
> content="text/html; charset=iso-8859-1" />
> </head>
> <body>
> <?php
> // Connect to the database server
> $dbcnx = @mysql_connect('localhost', 'root', 'mypasswd');
> if (!$dbcnx) {
> exit('<p>Unable to connect to the ' .
> 'database server at this time.</p>');
> }
> // Select the jokes database
> if (!@mysql_select_db('ijdb')) {
> exit('<p>Unable to locate the joke ' .
> 'database at this time.</p>');
> }
> ?>
> <p>Here are all the jokes in our database:</p>
> <blockquote>
> <?php
> // Request the text of all the jokes
>
> $result = @mysql_query('SELECT joketext FROM joke');
> if (!$result) {
> exit('<p>Error performing query: ' . mysql_error() . '</p>');
> }
> // Display the text of each joke in a paragraph
> while ($row = mysql_fetch_array($result)) {
> echo '<p>' . $row['joketext'] . '</p>';
> }
> ?>
> </blockquote>
> </body>
> </html>
>
> Hope that helps.
>
> The problem is that the HTML produced stops after the <body> tag. Also,
> looking at my MySQL log, I do not see that any connection was made.
>
> I also tried mysqli_connect as well. That didn't work, either.
>
> Thanks.
>
Is your database on your local machine? Is the MySQL user id 'root' and the
password 'password'?
And take the '@'s off the beginning of your function calls. They may be hiding
errors.
Try turning on all errors in your PHP.INI file (error_reporting=E_ALL)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|