GaryZ
asked on
Using Script to create tables...
I am really just learning MySQL and PHP, and also have a project I need to get done with the deadline coming up soon.
The server that hosts the website does not allow me to use a command line, so I think I need to use scripts to create my tables. Andriv offered me the following code in another question:
$dbconnect = mysql_connect("host","user ","passwor d");
$mysql_select_db("dbName", $dbconnect );
$Query = "Create table tableName (prodid int(10) not null auto_increment,next field,next field)";
mysql_query($Query);
My question is, what do I surround the code with? HTML? PHP?
If PHP I would assume it would look like the following:
<?
code from Andriv, to build table and columns
?>
Then would I need an HTML form to run the PHP, like this?
<html>
<head>
</head>
<body>
<form action="xxxx.php" method=post>
<table border=0>
<tr>
<td colspan=2 align=center><input type=submit value="Submit Order"></td>
</tr>
</table>
</form>
</body>
</html>
I really appreciate the help.
The server that hosts the website does not allow me to use a command line, so I think I need to use scripts to create my tables. Andriv offered me the following code in another question:
$dbconnect = mysql_connect("host","user
$mysql_select_db("dbName",
$Query = "Create table tableName (prodid int(10) not null auto_increment,next field,next field)";
mysql_query($Query);
My question is, what do I surround the code with? HTML? PHP?
If PHP I would assume it would look like the following:
<?
code from Andriv, to build table and columns
?>
Then would I need an HTML form to run the PHP, like this?
<html>
<head>
</head>
<body>
<form action="xxxx.php" method=post>
<table border=0>
<tr>
<td colspan=2 align=center><input type=submit value="Submit Order"></td>
</tr>
</table>
</form>
</body>
</html>
I really appreciate the help.
ASKER
Will this run on Windows 2000 or only on the host server?
u have to upload that t ur server..
u can try this also...
<?
if($submit){
$dbconnect = mysql_connect("host","user ","passwor d");
$mysql_select_db("dbName", $dbconnect );
$Query = "Create table tableName (prodid int(10) not null auto_increment,next field,next field)";
$result=mysql_query($Query );
if(!$result){
echo "Error:".mysql_error();
}
}
else{
?>
<html>
<head>
</head>
<body>
<form action="<?=$PHPSELF?>" method=post>
<table border=0>
<tr>
<td colspan=2 align=center><input type=submit name=submit value="Create Table"></td>
</tr>
</table>
</form>
</body>
</html>
<?}?>
Hope this helps...
LK
u can try this also...
<?
if($submit){
$dbconnect = mysql_connect("host","user
$mysql_select_db("dbName",
$Query = "Create table tableName (prodid int(10) not null auto_increment,next field,next field)";
$result=mysql_query($Query
if(!$result){
echo "Error:".mysql_error();
}
}
else{
?>
<html>
<head>
</head>
<body>
<form action="<?=$PHPSELF?>" method=post>
<table border=0>
<tr>
<td colspan=2 align=center><input type=submit name=submit value="Create Table"></td>
</tr>
</table>
</form>
</body>
</html>
<?}?>
Hope this helps...
LK
And please always use <?php ?> to embedd your php code, because not every environment accepts <? ?>
PP
PP
GaryZ -
phpMyAdmin runs on the server ... it's a GUI frontend to MySQL, enabling you to add/edit/delete tables, add/edit/delete records, - in short, control the whole database. On your local machine, edit config.inc (to add your username, password and database name) then use FTP to upload all the files to your server, for example, into a new subdirectory (under the web root dir) called "phpmyadmin". Then point your browser to http://www.yourdomain.com/phpmyadmin/index.php3 and you're off and running ...
PHPAccess is a similar process, although there's nothing to edit ahead of time. Use FTP to upload the file intpo /phpmyadmin, then point your browser to http://www.yourdomain.com/phpmyadmin/phpaccess.php to run the script. This script allows you to add/edit/delete Usernames and Passwords controlling access to all files in the subdirectory /phpmyadmin where it's located. Now, when you go to phpmyadmin/index.php3 you'll be challenged for your username and password ...
Let me know if I can help you walk through all this ...
Bob.
phpMyAdmin runs on the server ... it's a GUI frontend to MySQL, enabling you to add/edit/delete tables, add/edit/delete records, - in short, control the whole database. On your local machine, edit config.inc (to add your username, password and database name) then use FTP to upload all the files to your server, for example, into a new subdirectory (under the web root dir) called "phpmyadmin". Then point your browser to http://www.yourdomain.com/phpmyadmin/index.php3 and you're off and running ...
PHPAccess is a similar process, although there's nothing to edit ahead of time. Use FTP to upload the file intpo /phpmyadmin, then point your browser to http://www.yourdomain.com/phpmyadmin/phpaccess.php to run the script. This script allows you to add/edit/delete Usernames and Passwords controlling access to all files in the subdirectory /phpmyadmin where it's located. Now, when you go to phpmyadmin/index.php3 you'll be challenged for your username and password ...
Let me know if I can help you walk through all this ...
Bob.
ASKER
OK. I have downloaded the file and unzipped it into a directory. Now I need to configure the config.inc.php3 file.
It says to change host,user, password, and authentication mode.
The ISP sent me the name of the database they created, plus the username and password. Is the host the domain name? What about the authentication mode?
It also appears that these have to be changed in more than one spot?
The database will contain inventory information and will be accessed by a search form from the internet. There is not special login needed, anyone should be able to do the search.
It says to change host,user, password, and authentication mode.
The ISP sent me the name of the database they created, plus the username and password. Is the host the domain name? What about the authentication mode?
It also appears that these have to be changed in more than one spot?
The database will contain inventory information and will be accessed by a search form from the internet. There is not special login needed, anyone should be able to do the search.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Gary --
Sorry, the code I quoted starts at line 46 of config.inc.php3 ... you can safely delete lines 69 through 99 inclusive, as you'll only be using this installation for 1 database.
Bob.
Sorry, the code I quoted starts at line 46 of config.inc.php3 ... you can safely delete lines 69 through 99 inclusive, as you'll only be using this installation for 1 database.
Bob.
ASKER
I have it loaded and renamed the php3 to php, I get the following error when I try to run index.php. It appears that maybe the hosting domain does not have something set up of I need to get a path from them
Fatal error: Failed opening required './libraries/grab_globals. lib.php' (include_path='')
Fatal error: Failed opening required './libraries/grab_globals.
Gary --
It's referring to a file that should be in the dir /libraries under phpMyadmin ... did you create the dirs phpMyadmin/libraries, phpMyadmin/lang and phpMyadmin/images on the server and upload the files in those corresponding subdirs from your drive to the server?
Bob.
It's referring to a file that should be in the dir /libraries under phpMyadmin ... did you create the dirs phpMyadmin/libraries, phpMyadmin/lang and phpMyadmin/images on the server and upload the files in those corresponding subdirs from your drive to the server?
Bob.
ASKER
I have to chagne all references to php3 to php. PHP3 does not work on the server.
ASKER
Yep, that was the problem, came right up (Oh, you also have to configur the line that has the path to the mySQLAdmin directory).
One last question. I downloaded the phpaccess and unzipped. There is no documentation, do I just load the script htaccess.class.php to the server and run it to set the username and password?
One last question. I downloaded the phpaccess and unzipped. There is no documentation, do I just load the script htaccess.class.php to the server and run it to set the username and password?
Gary --
Yes, that's it ... but the file I downloaded has just 1 PHP script named phpaccess.php - no associated class, just the script.
This script creates and manages access to the subdirectory in which you place it, and from which you run it. Should you ever need to get rid of challenge-response access to that dir, delete the files .htaccess and .htpasswd, which phpaccess creates and manages for you.
You do need to protect this directory, and phpaccess is the easiest way to do that.
Bob.
Yes, that's it ... but the file I downloaded has just 1 PHP script named phpaccess.php - no associated class, just the script.
This script creates and manages access to the subdirectory in which you place it, and from which you run it. Should you ever need to get rid of challenge-response access to that dir, delete the files .htaccess and .htpasswd, which phpaccess creates and manages for you.
You do need to protect this directory, and phpaccess is the easiest way to do that.
Bob.
Gary --
You can make your PHP installation handle files with .php3 by adding the following line to the .htaccess file in the main directory:
AddType application/x-httpd-php .php3
If the main dir does not already have a file named .htaccess, then create one with the single line and upload it ... the line forces Apache to hand files named .php3 off to PHP. Obviously the line
AddType application/x-httpd-php .html
... would do the same for all files with .html, too.
Bob.
You can make your PHP installation handle files with .php3 by adding the following line to the .htaccess file in the main directory:
AddType application/x-httpd-php .php3
If the main dir does not already have a file named .htaccess, then create one with the single line and upload it ... the line forces Apache to hand files named .php3 off to PHP. Obviously the line
AddType application/x-httpd-php .html
... would do the same for all files with .html, too.
Bob.
ASKER
Thanks for the help. I will probably be back for more.
You will probably want to password-protect the subdirectory where you put the program - if you have Telnet access, you can do this with an .htaccess and .htpasswd file ... otherwise, look for another project on SourceForge called "phpaccess" -- put this script in the same subdir as phpMyAdmin and run it to create the password protection you need.
This is an overview - please let me know if I can give you any other details ...
Bob.