Click to See Complete Forum and Search --> : Could someone point me in the right direction?


lmccord2
05-13-2003, 09:01 PM
I'm building a gaming site, and I need to get some database (not mySQL, please, I can't even get it installed, I'm no PHPist :p) where I can have an admin and add a category from it (which would be playstation 2, xbox, etc) and then categories inside those (the games) and in the games, I can add all the cheats, hints & tips, reviews etc from the admin. I just need to be pointed in the right direction. Thanks...

pyro
05-13-2003, 10:33 PM
Generally, when one uses PHP, mySQL is the database that is used. What exactly are you looking for?

AdamGundry
05-14-2003, 09:36 AM
MySQL is probably the best database to use, though I believe PostgreSQL might be an option, though I haven't tried it myself.

If you are using MySQL, phpMyAdmin is a very useful tool:
http://www.phpmyadmin.net/

Adam

lmccord2
05-14-2003, 10:15 AM
I tried phpMyAdmin before... I couldn't get it installed either rofl. I'll try again. Thanks anyways.

lmccord2
05-15-2003, 01:05 PM
Auctually, could someone just give me some PHP code that will write some text to a file and another PHP code to get the text in the file?

AdamGundry
05-15-2003, 01:32 PM
To get the text in a file (straight dump to browser):<?php include "filename.txt" ?>To read the file and parse newlines to <br>s (suitable for HTML):<?php
$text_array = file("filename.txt");
$text = implode("", $text_array);
print nl2br($text);
?>To write to a file (example from www.php.net):<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
}

// Write $somecontent to our opened file.
if (!fwrite($handle, $somecontent)) {
print "Cannot write to file ($filename)";
exit;
}

print "Success, wrote ($somecontent) to file ($filename)";

fclose($handle);

} else {
print "The file $filename is not writable";
}
?>

Adam

pyro
05-15-2003, 01:33 PM
To write to a file: (file must be CHMODed to 666)

<?PHP

$filename = "file.txt";
$text = "This is a demo.";

$fp = fopen ($filename, "w");
if ($fp) {
fwrite ($fp, $text);
fclose ($fp);
echo ("File written");
}
else {
echo ("File was not written");
}

?>

To read from a file:

<?PHP

$filename = "file.txt";

$fp = fopen ($filename, "r");
if ($fp) {
$text = fread ($fp, filesize ($filename));
fclose ($fp);
echo $text;
}
else {
echo ("File is not readable");
}

?>