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();


?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.