Re: Not bale to connect to MySQL with PHP [message #169651 is a reply to message #169650] |
Tue, 21 September 2010 16:40 |
MikeB
Messages: 65 Registered: September 2010
Karma:
|
Member |
|
|
Denis McMahon wrote:
> On 21/09/10 15:47, MikeB wrote:
>
>> I tried it and it seems to connect to something. I get this:
>>
>> telnet localhost 3306 and then:
>>
>>> B
>>> 5.1.49-community-lo6IJyD%*☻L9wl8qR&cA[(
>>
>> and a few seconds later I get:
>>
>>> Connection to host lost.
>>>
>>> C:\Users\Mike>
>
> OK, that's almost what happens on my working system, except that I don't
> see any text from the mysql connection.
>
> However, I overlooked this:
>
>> <?php
>> Echo "Hello";
>> require_once 'login.php';
>> echo "got require";
>
> You didn't say whether any of these echoes were sent to the browser?
The echos only get sent to the browser when I //-comment out the
mysql_connect statement.
>
> Also, as you're in the document body, it's a good idea to wrap those
> echoes in suitable html element tags, eg:
>
> <?php
> Echo "<p>Hello</p>";
> require_once 'login.php';
> echo "<p>got require</p>";
>
> and see what happens if you comment out the database stuff:
See above, 'cept I just let the debugging stuff run on to one line.
>
> /*
> $db_server = mysql_connect($db_hostname, $db_username, $db_password);
> if (!$db_server)
> die("Unable to connect to MySQL: " . mysql_error());
> echo "Congrats, it seems you have connected to the server<br />
> host: $db_hostname<br />
> user: $db_username<br />
> password: $db_password<br />
> for database: $db_database<br />";
> print_r($db_server);
> */
>
> ?>
>
> Just to check the underlying php / html functionality.
>
> You could also add the following after 'echo "<p>got require</p>";'
>
> echo "<p>db info: user = '$db_username', host = '$db_hostname', pw =
> '$db_password'</p>";
Did this also. I get the values in the login.php file. But again, only
if I comment out the mysql_connect statement. If I don't, it just hangs
the entire browser window indefinitely. I just copied the "success" echo
block of the code to before the mysqlL-connect statement.
I'm just plumb out of ideas.
I'm gonna try install a different WAMP package on another computer and
see if I get any further. :(
|
|
|