error is not showing

0 MAYANK JINDAL · April 29, 2015
error is not showing . here is my code please help me 

<?php
$mysql_host = 'localhost';
$mysql_user = 'mayank';
$mysql_pass = '';
mysql_connect($mysql_host,$mysql_user,$mysql_pass);
?>

Post a Reply

Replies

Oldest  Newest  Rating
0 Peer Ligthart · April 30, 2015
I see you are using normal MySQL, which is still working but in the near future PHP won't support MySQL any more. I'd advice you using MySQLi which has a pretty close syntax to MySQL, try this:

<?php

$conn = new mysqli('host','user','password','db_name'); //that will connect you to your database, you can change the $conn variable into whatever you like.

//error handling

if(mysqli_connect_errno()) {
      echo 'Error: ', mysqli_connect_error();
} else {
       //successfully connected
}

?>

You can just leave this last 'else' statement away, it's not necessary.

For more information, check: http://www.w3schools.com/php/php_mysql_intro.asp
  • 1

PHP

107,039 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators