Jump to content


  • Posts

  • Joined

  • Last visited


About xdracox

  • Birthday 05/09/1990

Contact Methods

  • AIM
  • MSN

Profile Information

  • Gender
  • Location
    Texas, USA

xdracox's Achievements


Newbie (1/5)



  1. The solution to your problem is called recursion. A recursive function is a function that calls itself over and over again doing something slightly different every time until a stop condition is encountered. For example, in pseudo-code your application would look something like this: $link = mysqli_connect(...); // A node is considered a person in the tree, a node has parents and children. function displayTreeNode($node) { 1. Use the existing database connection ($link) to obtain the data about the node. 2. Display the current node. 3. Check for any relationships to other nodes and call displayTreeNode() for each of those nodes. 4. If no more relationships exist, exit the function. }
  2. Before your while loop, declare a variable $position = 0. Then, at the end of each while loop, increment the $position variable by one. Then you can use the $position variable inside your while loop wherever you need it to. Here's the code: <?php $result = mysql_query("SELECT * FROM sv_newsbrief ORDER BY ID DESC LIMIT 12", $connection); if (!result) { die("Database query failed: " . mysql_error()); } $position = 0; // this was added while ($row = mysql_fetch_array($result)) { $filename = $row["filename"]; $issue = $row["issue"]; $item1 = $row["item1"]; $item2 = $row["item2"]; $item3 = $row["item3"]; echo "<li><a target='_blank' href='../images/Newsletters/PDF/" . $filename . "'>" . $issue . "</a> <ul class='subNews'> <li class='preview'>In This Issue:</li> <li>" . $item1 . "</li> <li>" . $item2 . "</li>"; if ($item3 == "") { } else { echo "<li>" . $item3 . "</li>"; } echo "</ul> </li>"; $position++; // increment the position } ?>
  3. Use the strpos() function. $string = 'Find the word swear.'; if ( strpos($string, 'swear') !== false ) { echo 'I found swear!'; }
  4. Derived classes always inherit public and protected members from their base classes. Example: class A { public function aMethod() { echo 'A::aMethod()!'; } } class B extends A { public function bMethod() { echo 'B::bMethod()!'; } } $obj = new B; $obj->aMethod(); $obj->bMethod(); Output: A::aMethod()! B::bMethod()!
  5. Try calling exit() after your call to header() so that the script stops executing.
  6. Why would I negate the '?'? I want Home?opt=val to map to index.php?p=Home&opt=val.
  7. RewriteRule ([A-Z0-9]+)[/]?$ index.php??=$1 [NC] Might work.
  8. I am trying to make my page be something like example.com/Home, example.com/Login, etc. But I also want to add a query string to it, like example.com/Home?article=100, or something. I managed to write the RewriteRule for the first part, but I can't seem to do the part with the query string. This is what I have so far: RewriteRule ^([A-Z][A-Za-z0-9]+)[\?]?(.*)$ index.php?p=$1&$2
  9. So I decided to make an SDL module for PHP. I have had to adjust to somethings since PHP is made in C. But that's all taken care of. If any of you know SDL, you know there is a function called SDL_GetVideoSurface(), this is the function I am having trouble with. I created SDL_SetVideoMode() like this: [code]/** setup a video mode with the specified width, height, and bpp *    @param    long width *    @param    long height *    @param    long bpp *    @param    long flags *    @return    resource (SDL_Surface) */ PHP_FUNCTION(sdl_setvideomode) {     long width, height, bpp, flags;     SDL_Surface *surface;          if ( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &width, &height, &bpp, &flags) == FAILURE )         return;          surface = SDL_SetVideoMode(width, height, bpp, flags);          if ( !surface )     {         php_error(E_WARNING, "%s() failed to set video mode to %dx%dx%d: %s",             get_active_function_name(TSRMLS_C), width, height, bpp, SDL_GetError());         RETURN_FALSE;     }          ZEND_REGISTER_RESOURCE(return_value, surface, le_surface); }[/code] And so far, I have this for SDL_GetVideoSurface() [code]/** returns a handle to the current display surface *    @return    resource (SDL_Surface) */ PHP_FUNCTION(sdl_getvideosurface) {     SDL_Surface *screen;     zval **surface_handle;          screen = SDL_GetVideoSurface();     if ( !screen )     {         php_error(E_WARNING, "%s() failed to get current display surface: %s",             get_active_function_name(TSRMLS_C), SDL_GetError());         RETURN_NULL();     }          // ZEND_FETCH_RESOURCE(screen, SDL_Surface *, surface_handle, -1, le_surface_name, le_surface); }[/code] So, my question is, what exactly do the arguments of ZEND_FETCH_RESOURCE() need to be? EDIT: This seems to be the first real Core PHP Hacking question in a while...
  • 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.