1 registered members (AndrewAMD),
972
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: PHP help
[Re: Inestical]
#202125
04/13/08 14:42
04/13/08 14:42
|
Joined: Jan 2008
Posts: 1,580
Blade280891
OP
Serious User
|
OP
Serious User
Joined: Jan 2008
Posts: 1,580
|
ok, kool, aaron this code will really help
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: PHP help
[Re: Blade280891]
#202137
04/13/08 16:12
04/13/08 16:12
|
Joined: Jan 2008
Posts: 1,580
Blade280891
OP
Serious User
|
OP
Serious User
Joined: Jan 2008
Posts: 1,580
|
when i used your code to test it, i get this error Fatal error: Call to undefined function: mysql_create_db() in /home/www/deanwhitehouse.awardspace.co.uk/databaseinfo.php on line 21 this is the line it is talking about if (mysql_create_db($db_name))
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: PHP help
[Re: Blade280891]
#202140
04/13/08 16:44
04/13/08 16:44
|
Joined: Nov 2003
Posts: 698 England, UK
Aaron_H
User
|
User
Joined: Nov 2003
Posts: 698
England, UK
|
As I said in the README, some servers don't allow databases to be created by that script (it would be a security flaw), I only used it because I was testing it on a local apache server.. What you will want to/need to do is create a new mySQL database on your server, and create a file called config.inc.php with: <?php
$db_host = HOSTADDRESS;
$mysql_user = USERNAME;
$mysql_pass = PASSWORD;
$db_name = DATABASENAME;
?> Looking at config_write.php explains this. After you've created this file, it will allow db_driver.php to connect to the database. You would then need to run db_update.php to add the necessary tables. On it's own the code doesn't really do much, it's just a bunch of small files not really linked together in any way. After my chemistry investigation and final exams I may carry on working on the code and start linking it together, because at the moment it's just a mess. If you have any more problems just post here and I'll try and help with what I can remember. I've not really used the code in a long long time and I don't have apache set up to test. Oh and read the README, it should help explain things a bit better.
|
|
|
Re: PHP help
[Re: Aaron_H]
#202142
04/13/08 16:48
04/13/08 16:48
|
Joined: Jan 2008
Posts: 1,580
Blade280891
OP
Serious User
|
OP
Serious User
Joined: Jan 2008
Posts: 1,580
|
Yer, the readme is just a file, with no extension ,although i have already adjusted to code to my needs, check it out so far on
Thanks for the help, everyone, i was really stuck on how to save there database details.
Last edited by Blade28081991; 04/13/08 17:04.
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: PHP help
[Re: Blade280891]
#202143
04/13/08 16:51
04/13/08 16:51
|
Joined: Nov 2003
Posts: 698 England, UK
Aaron_H
User
|
User
Joined: Nov 2003
Posts: 698
England, UK
|
Yeah, sorry about that. I'm using Linux and you don't normally need an extension to view a file in a text editor. And if I were you I wouldn't post that link.. It would make more sense to delete that file once the database is set up I'm glad it helped though. [EDIT: Oh, it's only a HTML file with no php behind it. Nevermind. :P]
Last edited by Aaron_H; 04/13/08 16:52.
|
|
|
Re: PHP help
[Re: Aaron_H]
#202145
04/13/08 17:05
04/13/08 17:05
|
Joined: Jan 2008
Posts: 1,580
Blade280891
OP
Serious User
|
OP
Serious User
Joined: Jan 2008
Posts: 1,580
|
delete the database setup file??
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: PHP help
[Re: Aaron_H]
#202156
04/13/08 17:37
04/13/08 17:37
|
Joined: Jan 2008
Posts: 1,580
Blade280891
OP
Serious User
|
OP
Serious User
Joined: Jan 2008
Posts: 1,580
|
well, this is a website system like,E107 so i will put instructions in it to delete it, or is there anyway to delete automaitcally using PHP. Also is there a way to stop them continuing untill the file is deleted?
Last edited by Blade28081991; 04/13/08 17:44.
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: PHP help
[Re: Blade280891]
#202174
04/13/08 18:29
04/13/08 18:29
|
Joined: Nov 2003
Posts: 698 England, UK
Aaron_H
User
|
User
Joined: Nov 2003
Posts: 698
England, UK
|
Well, it is only usually the admin of the server that needs to set up the database (usually on the install). So you can just tell them in the installation instructions to delete the file once they've setup the server. Or you can do a test with index.php or some other file that first loads after they've setup the sever like so: <?php
$filename = "db_update.php";
if (file_exists($filename)) {
echo "Please remove db_update.php";
} else {
// The rest of your code goes here.
}
?>
|
|
|
Re: PHP help
[Re: Aaron_H]
#202176
04/13/08 18:41
04/13/08 18:41
|
Joined: Jan 2008
Posts: 1,580
Blade280891
OP
Serious User
|
OP
Serious User
Joined: Jan 2008
Posts: 1,580
|
Ok, thanks for that. I have a problem with a code, can u help.
<?php
// Random Game Design: PHP Website Template
// Version 1
// Copyright Dean Whitehouse, 2008
include 'db_connect.php';
include 'config_table.inc.php';
$sql_user = "CREATE TABLE "user"(
user_id int(10) AUTO_INCREMENT NOT NULL PRIMARY KEY,
user_name varchar(100) NOT NULL,
user_password varchar(100) NOT NULL,
user_email varchar(100) NOT NULL,
user_timezone char(3) NOT NULL,
user_hideemail tinyint(3) unsigned NOT NULL,
user_ip varchar(20) NOT NULL,
user_ban tinyint(3) unsigned NOT NULL,
user_realname varchar (40) NOT NULL,
user_age int(10) unsigned NOT NULL,
user_class varchar(100) NOT NULL
)";
$user= mysql_query($sql_user);
if ($user)
echo('<br>User Table Created');
else
echo('Tables Not Created');
?>
that should create the table with the user submitted name
<?php
// Random Game Design: PHP Website Template
// Version 1
// Copyright Dean Whitehouse, 2008
?>
<html>
<body bgcolor="#999999">
<p align="center"><font color="#000099" size="+2">Please enter the table names you want, or if you want to use the preset names click continue. NOTE: Each table must be a different name. Please do not leave any blank spaces.</font></p>
<table align="center" bgcolor="#333333" width="300px" border="0">
<form method='post' action='create_tablenames.php'>
<tr><td>
<font color="#FFFFFF">
User Details:</td><td>
<input type="text" name="user" value="rgd_users"><br></td></tr>
<tr><td></td><td><input type='submit' value='Continue' name='check'></td></tr>
</font>
</form>
</table>
</body>
</html>
this is how they submit the name
<?php
// Random Game Design: PHP Website Template
// Version 1
// Copyright Dean Whitehouse, 2008
include 'db_connect.php';
$dbhost = $_POST["dbhost"]; // Database Host
include ("config_writetable.php");
?>
this runs the config_writeable.php file
<?php
// Random Game Design: PHP Website Template
// Version 1
// Copyright Dean Whitehouse, 2008
$config_file = "config_table.inc.php";
$fw=fopen($config_file,"w+")
or die("Unable to open file!"); // Unable to open file
$user = "\$user = \"".$user."\";\n";
$config_write = $user;
fwrite($fw, "<?php\n".$config_write."\n?>");
fclose($fw);
?>
this writes the name to the .inc.php file This all works, except when i click run the page that creates the table, it doesnt create one. but i don't get any sql errors
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
|