mysqli_connect Isn't Connecting, But Isn't Not Connecting.

Toodles, y’all! o/ Back again, with another question (I have a feeling that I’m going to be posting here a lot [:P]). I have this code sitting in an html runner-thing (weebly’s html module, to be exact). Technically, it should attempt to connect to my server (yes, all the connection parameters are correct), and return one of two messages depending on wether it connects or not. Unfortunately, nothing happens. At all. Neither string is displayed, even though it’s a clear if/else statement. What might I be doing wrong here? Does the IP need to be more specific than merely localhost? Do I need to attach any scipts to the database somehow? Any help would be much appreciated. [:)]

[php]<?php
$con=mysqli_connect(“localhost”,“Name”,“Password”,“DatabaseName”);
// Check connection
if(mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
print “Hah! Did it”;
}
?>[/php]

Are you sure the page is being called?

Try changing this
[php]if(mysqli_connect_errno()) {[/php]
to
[php]if($con) {[/php]

Nope, still nothing.

[php] <?php
echo “IN CONNECTION.”;
$con=mysqli_connect(“localhost”,“Name”,“Password”,“DatabaseName”);
// Check connection
if(mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
print “Hah! Did it”;
}
?>[/php]

Nope, it doesn’t seem to be running it. After poking around, it appears that weebly’s html widget doesn’t allow php script (get it right, weebly). [:] Thanks for taking the time to help. [:)]

Sponsor our Newsletter | Privacy Policy | Terms of Service