Why isn't this php code allowing me to connect to my database? -



Why isn't this php code allowing me to connect to my database? -

i'm using wamp server , on created database , table. names right , user has total access everything. when run code, prints out "unable select database". thanks.

<?php if(isset($_post["submit"])){ print_r ($_post["nutrient"]); } session_start(); //establish connection $server = "localhost"; $db_username = "root"; $db_password = ""; $database = "gainlife_cavin"; $table = "cavintable"; //connect php script database $connection = mysqli_connect($server, $db_username, $db_password, $database); //select database utilize @mysql_select_db($database) or die( "unable select database"); //$query = "insert $table values("")" //mysql_query($query) mysql_close(); ?> <body> </form>

try following.

<?php //establish connection $server = "localhost"; $db_username = "root"; $db_password = ""; $database = "gainlife_cavin"; $table = "cavintable"; //connect php script database $connection =mysqli_connect("$server","$db_username","$db_password","$database"); if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } //your query here mysqli_close($connection); ?>

php database wamp

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -