Jump to content
MakeWebGames

Floydian

Members
  • Posts

    900
  • Joined

  • Last visited

    Never

Everything posted by Floydian

  1. Re: Call to a member function query() on a non-object - Error in my forum pog is right alternatively, you can leave that the same, and add $db to the global list global $ir, $c, $userid, $h, $bbc, $db;
  2. Re: MYSQL.PHP placing mysql close at the end of a script is likely to change nothing. php actually does you the favor of closing the database connection at the end of a script anyways, UNLESS you EXPLICITLY ask for a persistent connection. But don't take my word for it, make a script "page1.php" and connect to the database, but don't close the connection. Then make a page "page2.php" and put some queries in there, but don't open a connection. And watch, you won't be able to connect to the database, even if you load page1.php first, and then page2.php. ;) Web host, it really does sound like something they need to fix.
  3. Re: Need help with my game! yeah we can help you
  4. Re: Ranking System idea   Jeezus christ, when you do the comparison if($rank != $ir[rank]) You're going to be comparing an INTEGER to a STRING That's what I've been trying to tell you, you need to just go with $rank, and only use that array when you wanna show someone their rank. ______________________ Anyways, that's a moot point as you say you have it working. I see you did go with $rank in the query in the end. You're welcome.
  5. Re: Ranking System idea   it compares the $rank variable not $rank_array, im not verry good with arrays so it probly wont work anyway lol   But look at how your query is: $query = "UPDATE users SET rank = ".$rank_array." WHERE userid = ".$userid;   Number one, you're attempting to store the rank as #3 or whatever my rank would be, so the next time you run the script, your comparison fails. Believe it or not, I'm 110% certain of that fact. Even worse is the fact that your intentions of storing the #5 in the database table will not work in the first place and will throw a mysql error. You would know this if you had added to this line: mysql_query($query) or echo mysql_error();
  6. Re: Ranking System idea you're going to want to store that rank as a number, and not with the # symbol attached to it.   if($rank != $ir[rank]) { when you compare $rank to #5 for example, that #5 will become a 0 for all intents and purposes, as it will be converted to an integer. so just store $rank in that query ;)
  7. Re: cron job for bank not working pls help me out Do you have Cpanel on your web host? I personally haven't seen one that doesn't have PHP MyAdmin on it. Regardless, when something isn't working right with code pertaining to a database query, it's standard to test the query out in a query browser. PHP MyAdmin is usually the way to do this.
  8. Re: Crons stoped working. lol You're the lazy one! Since you wanna throw out a british cuss word, lemme give you an American one back at you.   Your fucking idiot because you think you're crons immune to failing because you're on a dedi. Call your fucking web host.   Feel free to insert "bloody" for each instance of "fucking". :)
  9. Re: Debug POST and GET submissions Thanks ;) That's right, you can add a second optional argument: $function = 1 where if $function = 1, vardump is used, if $function = 2, print_r is used, and so on. or, it can simply be added to the switch, and the $type argument. One could also pass the $ir (mccodes style) array and test if the person is staff level, in case this function is called and left in a script that is uploaded live. At least then, it wouldn't be visible to players ;)
  10. Re: Query Help If I remember correctly, the diff queries are in an if else block. That means using the two variables you have up there conflict with each other. You can only use one at a time. My suggestion: Use one, and write a query to get the data for the other.
  11. Re: Crons stoped working. Contact your web host.
  12. Re: cron job for bank not working pls help me out Have you tried running either of these queries in php my admin?
  13. Re: Crons stoped working. Being on a dedicated server doesn't preclude the possibility of your crons daemon from needing to be restarted by your hosting company. Just such a thing happened when I was admin on Cove of Pirates.
  14. Re: cron job for bank not working pls help me out I'm assuming this is the relevant portion here: $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/50) where bankmoney>0"); $db->query("UPDATE users SET cybermoney=cybermoney+(cybermoney/100*7) where cybermoney>0");   Is it doing nothing? Have you tried running either of these queries in php my admin? syntactically speaking, there doesn't appear to be anything wrong with them.
  15. Re: An introduction to security [note: Akash posted while I was typing mine, I read that post, and am leaving mine as it was originally stated.] Akash is defining the column names, but is doing so in a roundabout way. There's nothing more secure than defining a query with a hard coded string.   $query = "update table1 set columna = columna +1";   However, you can do this:   $query = sprintf('update %s ser %s = %s + %d', 'table1', 'columna', 'columna', 1);   Both are the same in terms of being hard coded as a string. The difference being there's completely unnecessary formatting happening in the second one. And if you were to accept a column name from a user as a means to determine which column to update, you better have defined a list of columns they are alowed to update. Accepting a column name from a user would be the only reason I could see passing the column name from the sprintf arguments. And even in that case, since you should have defined a white list of column names allowed, there would be 0% need for any escaping...   $allowed_columns = array('strength', 'defense', 'intel'); if (!in_array($_POST['column_name'], $allowed_columns) ) { die('suckaz'); }
  16. Re: I want to make/own my own game, please help /vorless throws the book... :mrgreen:
  17. Re: right side mainmenu Just a lil joke: Is this an arabic site? _______________________________ Have you tried moving the function call for the main menu from the beginning of a page to the end? if you have a table with two rows, and two columns, you'll need to add a third column Your layout is likely something like that ____________________ |-----|---------------| |-----|---------------| |-----|---------------| |____|_____________| |-----|---------------| |-----|---------------| |-----|---------------| |-----|---------------| |-----|---------------| |-----|---------------| |-----|---------------| |____|_____________|   You'll need something like this: |-----|---------------| |-----|---------------| |-----|---------------| |____|_____________| |---------------|-----| |---------------|-----| |---------------|-----| |---------------|-----| |---------------|-----| |---------------|-----| |---------------|-----| |_____________|____|   Of course that means adding a column, and making the wide space up top and on the right span 2 columns and making the wide space on the bottom and on the left span 2 columns To illustrate where the way the table is layed out, I'll use ! for a "hidden" seperator, i.e, a place where two cells join together   |-----|---------!-----| |-----|---------!-----| |-----|---------!-----| |____|________!____| |-----!---------|-----| |-----!---------|-----| |-----!---------|-----| |-----!---------|-----| |-----!---------|-----| |-----!---------|-----| |-----!---------|-----| |____!________|____|   Since your main menu function should contain it's on starting <td> and ending </td> tags, you should be able to call the function later on   and just edit the rest of the table to adding colspans to the two cells that will need them.
  18. Re: I want to make/own my own game, please help Yes wise one, imbue me with a double portion of magic please!
  19. Re: Clocking the speed of a page load. I'm not sure what's making it not work in globals.php and the Header::endpage() method, but there are ways to pass the variables from one place to another. Perhaps you aren't including the appropriate variables in the right places. For instance, through the use of global $blah; or protected $blah and $this-blah. If you're using php 5, which I assume you are, then in the Header class, you should have some properties defined: protected $start_time = null; protected $end_time = null; in the Header::start_headers() method you should do something like: $this->start_time = blahblahblah;   in the Header::end_header() method you will now be able to use the $this->start_time property because you've defined it as a protected property of the class and you can refer to it using the reserved variable "$this" as in $this->property. The $end_time variable would only be used in the Header::end_header() method, but for consitency's sake, I'd make it a property as well, and refer to it as $this->end_time.
  20. I've found that one of the biggest problems with making forms that people have when things aren't working the way they intended, is that they don't know what's being sent from one script to another.   function _display($type = 'request') { echo '<div align="left">'; if ($type == 'request') { echo "<pre>". print_r($GLOBALS['_REQUEST'], 1). "</pre>"; } elseif ($type == 'all') { echo "<pre>". print_r($GLOBALS, 1). "</pre>"; } elseif ($type == 'session') { echo "<pre>". print_r($GLOBALS['_SESSION'], 1). "</pre>"; } echo '</div>'; }   _display(); is a function I use a lot when things aren't working for me. It shows me exactly what is being sent in the form. I can't stress enough how helpful it is to actually SEEEEEEEEEEEE what is being passed. Once you see what is being passed, you'll most likely find that debugging your script becomes quite a bit easier. This function has other uses as well. _display('all') shows you every variable you have set. very handy..... _display('session') shows you everything set in your $_SESSION array. Note that _display() shows you the REQUEST array which is a compilation of POST, GET, and COOKIE arrays. Have fun with it!
  21. Re: Clocking the speed of a page load. microtime true only works in php >= 5 go to the php site, and look up microtime, and you'll see a script that's ready made for timing scripts in php 4, and in php 5 it's READY MADE, just copy, paste, and insert the code you wanna time in the middle. php.net/microtime should get you there
  22. Re: Need help with creating a php/mysql powered page. My post was complimentary :S I guess my efforts weren't appreciated. Care to let us know where one would go to get free work done? I have tens of thousands of lines of code I would love to nickel and dime off of them....
  23. Re: Need help with creating a php/mysql powered page. Basically, you want me to write the entire script for you? I charge for that sort of thing. I gave you something to go on. If you're not willing to do anything with it, then you'll have to part with some cash.
  24. Re: Need help with creating a php/mysql powered page. I'm just going to post this real quick and come back and edit the post with an answer for you. Very IMPORTANT: It is highly recommended that you take down that php info page, and don't put it up again. That script contains way more info than you want people to get their hands on. I'm sure others will confirm this. ######################################## <?php define("HOST", "localhost"); define("USER", "user_name"); define("PASS", "my_password"); define("DB", "database_database"); $con = mysql_connect(HOST, USER, PASS); mysql_select_db(DB); $q_data = mysql_query('select column_a from table_1 where column_b = some_value'); $my_data = null; while($row = mysql_fetch_array($q_data)) { $my_data .= <<<EOT Somthing to click on [url="blah.php?action=foo&id={$row['column_a'];}"]here.[/url] EOT; } echo <<<EOT <h2>Let's see if we got anything from the database...</h2> $my_data <hr> Did anything appear from the database? EOT; ?>
  25. Re: Fatal error: Call to a member function query() on a non-object Here's what that means (this is what the tc was asking for folks...) Fatal error: Call to a member function query() on a non-object somewhere in the code, a function is called by the name of "query();". This function has not been defined. Sample function definition:   function query() { echo "Our function: query, is now defined."; }   Another way to go about defining it, would be within the context of a class. If you are using the mccodes vs database class "$db" then the method called "query()" is part of that class. $db->query(); if you leave out the $db-> and just put query(), or $db is not in the "scope" where you used $db at, then you'll get this error. Define query(), and you're problem is solved.
×
×
  • Create New...