Mysql query not executing in PHP | mysql query not working in php
Mysql query not executing in PHP
Reasons why Mysql query is not executing in PHP
⦁ you might missed establishing connection with database⦁ you might trying to execute query before establishing connection with database⦁ your database connection query might be worng⦁ your query might be wrong ⦁ Mysql server might be not runningTo establish connection with database query should be like this :
//Database Connection Var $db = mysqli_connect("localhost", 'user', 'password', 'database_name');you might trying to execute query before establishing connection with database
first of all create connection with database and get connection variable before try to execute any query.
your database connection query might be worng
if you are login as 'root' user then //Database Connection Var $db = mysqli_connect("localhost", 'root', ' ', 'database_name');
your query might be wrong
check your query eg: if query is to insert data then prepare your query as:$sql = "INSERT INTO table (`username`, `email`, `address`, `mobile no`) VAUES('" .$user."', '" .$email."', '" .$address."', '" .$mob"')";
How are you executing query
$query = mysql_query($sql) or trigger_error("Queryfailed : ".mysql_error()); - mysql_query($sql) should bemysql_query(Database_Connection_Var,$sql) ;
You might be missing database connection variable missed.
mysql_query($db,$sql) ;
Mysql server might be not running
if it is not green the restart WAMP
- if still it is not working then change port number of mysql server
- if all above methods not work then one way to reinstall your wamp server
- but if you reinstall it then you might loss your database
Comments
Post a Comment