Hi everyone,
Here is a code I wrote:
<?php
$con=mysqli_connect("localhost","root","rootpass","tivonidb");
if (mysqli_connect_errno($con))
{
<p class="SQLconnect">
echo "Failed to connect to MySQL: " . mysqli_connect_error();
</p>
}
else
{
echo "Success connecting to MySQL! " ;
}
?>
Here come an error message that accompanies the above code:
Parse error: syntax error, unexpected ‘<’ in C:\xampp\htdocs\ iv oni\scripts\ ivoni_connect.php on line 5
Can anyone tell me please where I went wrong?
Thanks
HTML script and PHP scripts must be separated with tags:
Try this
<?php
$con=mysqli_connect("localhost","root","rootpass","tivonidb");
if (mysqli_connect_errno($con))
{
echo '<p class="SQLconnect">';
echo "Failed to connect to MySQL: " . mysqli_connect_error();
echo '</p>';
}else{
echo "Success connecting to MySQL! " ;
}
?>
or this:
<?php
$con=mysqli_connect("localhost","root","rootpass","tivonidb");
if (mysqli_connect_errno($con)) { ?>
<p class="SQLconnect">
<?php echo "Failed to connect to MySQL: " . mysqli_connect_error(); ?>
</p>
<?php }else{ echo "Success connecting to MySQL! " ; }
?>
Small error for you, great progress for me !
Thanks a lot John !
I love the quote about small error:)