Jump to content

Adding tables to a Database...


Random

Recommended Posts

your connection in the script will be normal except your would obviously us the ip or domain name of the remote machine instead of localhost.

 

 

now on the remote machine every user has an attribute as to where they are allowed to connect from, localhost is the most common, but that isn\'t gonna work for someone from a remote machine even if they know the correct u/n and pass. What sort of admin software do you use on the mysql machine, phpmyAdmin?

Link to comment
Share on other sites

Is there a way to add a table to a database when I do not host the mysql databases? Like through a PHP script? Thanks in advance.

 

Now there are 2 ways of doing that

write a .sql file which would carry the table insert command

 

run the script to create the database.

 

now if u want to do from a program

 

its pretty simple to what u do

 

type in the query

 

$db = mysql_connect("localhost", "admin","admin");



mysql_select_db("db_name",$db);



$sql = "CREATE TABLE test (

 id int(11) NOT NULL auto_increment)";



$result = mysql_query($sql);

 

Hope this helps!!

Link to comment
Share on other sites

Is there a way to add a table to a database
$db = mysql_connect("localhost", "admin","admin");



mysql_select_db("db_name",$db);



$sql = "CREATE TABLE test (

 id int(11) NOT NULL auto_increment)";



$result = mysql_query($sql);

 

Will this work from a PHP script that I upload and execute in the server, if I just change localhost to the IP/Domain name of the server?

Link to comment
Share on other sites

$db = mysql_connect("localhost", "admin","admin"); 



mysql_select_db("db_name",$db); 

   

$sql = "CREATE TABLE test ( 

 id int(11) NOT NULL auto_increment)"; 



$result = mysql_query($sql) or die("Table not created");



echo "Table created sucessfully";

Link to comment
Share on other sites

im getting this error when I put in the script and changed it around to fit my needs:

 

Warning: mysql_connect() [function.mysql-connect]: Can\'t connect to MySQL server on \'random.travisbsd.no-ip.org\' (60) in /usr/home/random/pubhtml/database.php on line 2

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /usr/home/random/pubhtml/database.php on line 4

 

 

here is the script:

 

<?php

$db = mysql_connect("random.travisbsd.no-ip.org", "CENSORED","CENSORED"); 



mysql_select_db("random",$db); 

   

$sql = "CREATE TABLE test ( 

 id int(11) NOT NULL auto_increment)"; 



$result = mysql_query($sql);

?>

Link to comment
Share on other sites

update:

 

he told me to use localhost, and it worked to the point of no errors coming up, so I used a or die statement, and it went off. What could it be now? Localhost is right, and my names, etc. is all right. Thanks

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.