demonslayer1
demonslayer1

Reputation: 859

Can't connect to database with php

How come I can't connect to database?

Parse error: syntax error, unexpected 'mysql_query' (T_STRING) in C:\xampp2\htdocs\tutorials\abc.php on line 14

<?php


$user = 'root' ; 
$pass = 'gfcf' ; 

$db = 'testdb' ; 

$con = new mysql('localhost', $user , $pass , $db) or die("UNABLE TO CONNECT");

$selected = mysql_select_db($db,con) 


mysql_query(" CREATE TABLE people 
(

firstname varchar(15)

gender varchar()


)");



?>

Upvotes: 0

Views: 69

Answers (1)

John Conde
John Conde

Reputation: 219824

You're mixing mysql_ and mysqli_ functions:

$con = new mysqli('localhost', $user , $pass , $db) or die("UNABLE TO CONNECT");
$selected = mysqli_select_db($con,$db) 
mysqli_query($con, " CREATE TABLE people 
(
  firstname varchar(15)
  gender varchar()
)");

Upvotes: 1

Related Questions