Random Posted March 31, 2003 Share Posted March 31, 2003 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. Quote Link to comment Share on other sites More sharing options...
DocSeuss Posted March 31, 2003 Share Posted March 31, 2003 It is pretty easy actually, as long as the user name and password has the permission to connect to the mysql server remotly. Quote Link to comment Share on other sites More sharing options...
Random Posted March 31, 2003 Author Share Posted March 31, 2003 uh please post an example how? Quote Link to comment Share on other sites More sharing options...
DocSeuss Posted March 31, 2003 Share Posted March 31, 2003 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? Quote Link to comment Share on other sites More sharing options...
Random Posted March 31, 2003 Author Share Posted March 31, 2003 I have no idea, my friend hosts my site he lives in Arkansas, I live in Indiana. Quote Link to comment Share on other sites More sharing options...
shivabharat Posted March 31, 2003 Share Posted March 31, 2003 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!! Quote Link to comment Share on other sites More sharing options...
Random Posted March 31, 2003 Author Share Posted March 31, 2003 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? Quote Link to comment Share on other sites More sharing options...
metalblend Posted March 31, 2003 Share Posted March 31, 2003 yes, that will work as long as your host has given your account permission to remotely modify the database. Quote Link to comment Share on other sites More sharing options...
Random Posted March 31, 2003 Author Share Posted March 31, 2003 will it display anything, like \"Database Table Successfully Installed\" or something of that sort? And what if i goto that site over and over, it will only make one table, right? Quote Link to comment Share on other sites More sharing options...
shivabharat Posted March 31, 2003 Share Posted March 31, 2003 $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"; Quote Link to comment Share on other sites More sharing options...
Random Posted March 31, 2003 Author Share Posted March 31, 2003 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); ?> Quote Link to comment Share on other sites More sharing options...
shivabharat Posted April 1, 2003 Share Posted April 1, 2003 $db = mysql_connect(\"random.travisbsd.no-ip.org\", \"CENSORED\",\"CENSORED\"); Â Are u sure this is the host name \"random.travisbsd.no-ip.org\" Â u can also try giving the IP . Quote Link to comment Share on other sites More sharing options...
Random Posted April 1, 2003 Author Share Posted April 1, 2003 He said that the port may not be right..is that a possibility? Quote Link to comment Share on other sites More sharing options...
Random Posted April 2, 2003 Author Share Posted April 2, 2003 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 Quote Link to comment Share on other sites More sharing options...
DocSeuss Posted April 2, 2003 Share Posted April 2, 2003 lol, so your site that you are working on is actually located on the box in Arkansas. Quote Link to comment Share on other sites More sharing options...
Random Posted April 3, 2003 Author Share Posted April 3, 2003 yes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.