Jump to content

[SOLVED] Getting PHP to create a table in mysql.


jscix

Recommended Posts

Ok, I'm extreamly new to php/sql.. what i'm trying to do is create a table in mysql using a php script...

I'm not sure what i'm doing wrong here.. but I am getting the error

 

Fatal error: Call to a member function mysql_query() on a non-object in C:\wamp\www\PHP\Test\createtable.php on line 23

 

which is: $xx=$connection->mysql_query($query);

 

What am I doing wrong? Anyone? :/

 

<?php

include('db_connect.php');

$connection = mysql_connect($db_host, $db_username, $db_password);


if (!$connection){
die ("Could not connect to the database: <br />". mysql_error());
}

$query = '
CREATE TABLE `info` (
  `username` varchar(26) NOT NULL,
  `password` varchar(26) NOT NULL,
  PRIMARY KEY  (`username`)
)';

$xx=$connection->mysql_query($query);


// print ("$xx". mysql_error());

$connection->disconnect();


?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.