0

Sir, I am new to php. I have following codes to connect with mysql

<?php
// Connection variables
$host="localhost";
$username="root";
$password="";
$db_name="asia"; 

// Connect to host
$con=mysqli_connect($host, $username, $password);

// Connect result
if(!$con){
die '<script type="text/javascript">alert("Error Connecting to HOST")'. mysqli_connect_error($con).'</script>'; 
}
else
{
echo "Connected" . mysqli_error($con);
}

// Database Selection
$sel =mysqli_select_db($con,"$db_name");

// Database Selection result
if(!$sel){
die '<script type="text/javascript">alert("Error Connecting to database")'. mysqli_connect_error($con).'</script>'; 
}
else
{
echo "Database Selected" . mysqli_error($con);
}
?>

On this line

die '<script type="text/javascript">alert("Error Connecting to HOST")'. mysqli_connect_error($con).'</script>'; 

it says:
**Parse error: syntax error, unexpected ''<script type="text/javascript' (T_CONSTANT_ENCAPSED_STRING) in C:\wamp\www\connect.php on line 13

**

Actually I want to show alert messagebox.

Please let me know what am doing wrong?

2
Contributors
2
Replies
14
Views
3 Years
Discussion Span
Last Post by phphp
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.