Jump to content

tsilenzio

Members
  • Posts

    134
  • Joined

  • Last visited

    Never

Everything posted by tsilenzio

  1. Okay i been working on this install script for longer then i wanted to, I keep running into endless errors and its starting to really frustrate me i will post the script below and the errors i keep getting <?php /********************************************************** * This code is the majority of the script, all abstract * code has been removed, if for whatever reason you * need to see the rest of the code because I missed * something then just say so other then that i think * that i got all the code that you needed to understand * how it works. **********************************************************/ //-------- FUNCTIONS --- BEGIN ----------// function dbConnect() { global $db_hostname, $db_password, $db_username, $db_database; if ($conn = mysql_connect($db_hostname, $db_username, $db_password)) { if(!mysql_select_db($db_database, $conn)) { die("Couldnt select database:<br><br>" . mysql_error()); } else { return $conn; } } else { die("Couldnt connect to MySQL:<br><br>" . mysql_error()); } } function processQuery($query) { global $db_hostname, $db_password, $db_username, $db_database; $conn = dbConnect(); if($result = mysql_query($query, $conn)) { return $result; } else { die("Couldnt send query:<br><br>" . mysql_error()); } mysql_close($result); } function injectSQL($fileName) { $filePath = $_SERVER["DOCUMENT_ROOT"] . '/install/data/' . $fileName; if(!($handle = fopen($filePath, "r"))); { die("Failed to open file: " . $filePath); } $query = ""; $lines = explode("\n", fread($handle, filesize($filePath))); if(!(fclose($handle))) { die("Failed to close file: " . $filePath); } foreach($lines as $line) { if(!(strpos($line,"//") == 0) && $line != "") //check for commented lines or blanks { $query .= $line; if(!(strpos($line, ";") == false)) { if($fileName = "sql_data.sql") { $query = str_replace(array('admin_username', 'admin_password', 'admin_email', 'admin_race', '00000000000000'), array($loginName, $password, $email, $race, time()), $query); } processQuery($query); $query = ""; } } } } //------ FUNCTIONS --- END ------// // // Empty database then drop it // ---------------------------------------------------------------------------- // For those of u wondering i empty the db first because when it recreats it, // it will put all the values alreay in it back into it. I dont know why it just does. // ---------------------------------------------------------------------------- // dbConnect(); if($result = mysql_list_tables($db_database)) { while ($row = mysql_fetch_row($result)) { print_r($row); $table = $row[0]; $query = "TRUNCATE TABLE $table"; processQuery($query); $query = "DROP TABLE $table"; processQuery($query); } } else { die("MySQL Error: " . mysql_error()); } // // Create all needed tables // injectSQL("sql_tables.sql"); echo("Tables installed."); //Seee if it will even make it this far - Remove once working.. // // Load values into new tables // injectSQL("sql_data.sql"); echo("Data installed."); //Seee if it will even make it this far - Remove once working.. Result as of now: Failed to open file: /home/deathsea/domains/dsunlimited.info/public_html/install/data/sql_tables.sql and I cant figure out how to fix it any help would be MUCH MUCH MUCH appreciated!!! Thanks SOOO much in advance! - tsilenzio
  2. Thannx alot still sint 100% working but ill figure out whats wrong xD
  3. yes? maybe? no lol =/
  4. Well it could be that GD isnt enables or installed, also did u try just to make sure that lowercase wouldnt matter like: imagecreatefromgif() instead of ImageCreateFromGif() just to make sure lol =/
  5. Is there any way to enable system() on a server?
  6. forgot to ask is it possible to do mutiple "CREATE TABLE.." commands in a single query? or does it all have to be seperate for each CREATE? :s
  7. Like i was thinking: <?php //code above function injectSQL($filename) global $root_path; $handle = fopen($root_path . 'install/data/' . $filename, "r"); $query = ""; $lines = explode("\n", fread($handle, 1024768)); fclose($handle); foreach($lines as $line) { if(!(strpos($line,"//") == 0) && $line != "") //check for commented lines or blanks { $query .= $line; if(!(strpos($line,";") == false)) { if($filename = "sql_data.sql") { $query = str_replace(array('admin_username', 'admin_password', 'admin_email', 'admin_race', '00000000000000'), array($username, $password, $email, $race, time()), $query); } processQuery($query); //Function that loads the config.php file, connects to DB and processes query $query = ""; } } } } //more code // // Create all needed tables // injectSQL("sql_tables.sql"); // // Load values into new tables // injectSQL("sql_data.sql"); ?>
  8. Yea but the only problem is that its 2 files not a textarea =/
  9. yea i know but i dont want the ppl using my script to have to do it i mean liek what if they dont got phpMyAdmin? thanx though
  10. Using php how would i inject a whole .sql file filled with [CREATE tablename( data values and such) and INSERT INTO tablename] into a database using php code? :s
  11. i explaiend on first post because the database i use on the site will READD the data once i drop the table and if i create it down the line it will READD whatever data was inside it for some reason =/
  12. well here is the verzion i came up with... <?php require_once('config.php'); $result = mysql_list_tables($db_database); if (!$result) { print "DB Error, could not list tables\n"; print 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_row($result)) { $table = row[0]; $query = "TRUNCATE TABLE '$table'"; processQuery($query); $query = "DROP TABLE '$table'"; processQuery($query); } ?> processQuery connects to the database and does all that stuff for me..
  13. Ok first off i am a COMPLETE noob with AJAX however i was wondering if it use it for a PHP game or if its kidna easy to modify vars that get sent back to the database which will cause the user to get stuff alot faster..
  14. i have this sitting on my desktop but i dont need it at the momment lol when i get the time ill get it to work and post u the steps sorry kinda buzy right now =/
  15. no problem lwet me know if it works or not
  16. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title><Your Forum> :: Index</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" type="text/css" href="css/print.css" /> </head> <body> <div align="center"> <table width="800" height="50"> <tr> <td><p align="center"><Your Forum> :: Index </p> <table cellpadding="0" cellspacing="0" border="0" align="center" style="margin-left: 10px;"> <tr> <td class="maintab_active_first"></td> <td valign="top" class="maintab_active_back"> <a href="index.php">Home</a> </td><td class="maintab_active_last"> </td> <td valign="top" class="maintab_back"> <a href="help.php">Help</a> </td> <td valign="top" class="maintab_back"> <a href="profile.php">Profile</a> </td> <td valign="top" class="maintab_back"> <a href="members.php">Members</a> </td> <td class="maintab_last" valign="top"> <?php if (!isset($_SESSION['username']) == false) echo "<td valign='top' class='maintab_back'> <a href='logout.php'>Logout</a> </td>"; else{ echo "<td valign='top' class='maintab_back'> <a href='login.php'>Login</a> </td> <td valign='top' class='maintab_back'> <a href='register.php'>Register</a> </td>"; }?> </tr> </table> </td> </tr> </table> </div> <?php $host="*********"; // Host name $username="**"; // Mysql username $password="*************"; // Mysql password $db_name="*******"; // Database name $tbl_name="forum_main"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <div align="center"> <?php $board = $_GET['board']; if ($board == false) { echo "<table width='90%' border='0' align='center' cellpadding='3' cellspacing='1' bgcolor='#CCCCCC'> <tr> <td width='3%' align='center' bgcolor='#E6E6E6'><strong></strong></td> <td width='40%' align='center' bgcolor='#E6E6E6'><strong>Board</strong></td> <td width='27%' align='center' bgcolor='#E6E6E6'><strong>Topics</strong></td> <td width='16%' align='center' bgcolor='#E6E6E6'><strong>Posts</strong></td> <td width='14%' align='center' bgcolor='#E6E6E6'><strong>Last Post</strong></td> </tr>"; while($rows=mysql_fetch_array($result)){ // Start looping table row echo "<tr> <td align='center' bgcolor='#FFFFFF'></td> <td bgcolor='#FFFFFF'><a href='?board=".$rows['board']."'>".$rows['board']."</a><BR></td> <td align='center' bgcolor='#FFFFFF'>".$rows['topics']."</td> <td align='center' bgcolor='#FFFFFF'>".$rows['posts']."</td> <td align='center' bgcolor='#FFFFFF'>".$rows['lastpost']."</td> </tr>"; } } else { echo "This is a Board"; } ?> </div> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#E6E6E6"></td> </tr> </table> </body> </html> i think that fixed it lol..
  17. Ok from what you said it depends, if each user takes about 10kilobytes worth of settings (mostly strings) stored in a session var then when u mutiply that by 10,000 then it turns into 100megabytes of space on the harddrive which could need to be changed very freaquently so it depends on how fast the PC is and how much ram it has that the server runs on, also i think you should try to use a database as much as possible but im also inexperenced lol (also im sure its more liek numbers and not really long strings just stating worse scenario)
  18. Ok on my site for some reason if i dont emtpy a database then when i drop it and recreate it, it will have all the entrys still in it. So i was wondering if somone could help me determine some kind of script that will figure out how many tables there are, then emtpy them, after that drop the tables or is this impossible? - deathseaker Thanx in advance!
  19. ok and lastly when i use the select statement how does it retun it with the fetch_array()? And are the elements number 0 thru (columns - 1) or the elements are the name of the columns? or fields or what ever they are called?
  20. ok good idea but would it slow up server load laot if it initalized the data for every var in each class from the tables in MySQL? or not really I know that ODBC Databases r slow on my PC so i assumed evvery database is slow like that =/ not sure if mySQL is like lightning fast compared to it..
  21. like $result = 1 if it went sucessful or $result = 0 if unsecessful? :-\
  22. ok so does the result thingy a boolean or does it return the number of affected thigns so i knwo for the future (books dont really tell me this =/)
  23. yea i got it form here thanx so much man!!
  24. well let me ask this then if i have a class asigned to each user and each class has about 8 - 20 vars in it and there will be a class for each person logged in on each page that needs the information in it (like 90% of all my pages) then when there are about 500 - 4,000 ppl on the page at once will this cause the server to laggg REALLY bad or you dunno or what? I would assume it would but then again im no PHP / MySQL expert
×
×
  • 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.