Jump to content

Masna

Staff Alumni
  • Posts

    288
  • Joined

  • Last visited

Posts posted by Masna

  1.  

    Can anyone enlighten me on why this doesn't redirect and if there's a better / different way of achieving a redirect deep within a page?

    <?php
    echo"anything"; // remove this echo or even make it blank and it redirects as expected
    header("location:blah.php");
    ?>
    

    Once anything is outputted by a php page, php flushes the buffered implied headers (auto-generated unless explicitly defined otherwise, things like Content-Type) and starts generating a response for the HTTP request. Because of echo "anything";, you are forcing this to happen. Thus, any headers you try to set thereafter (however you do it, including using the header() function) are rendered useless. It'd be like trying to set an accept encoding in your POST body - it just makes no sense.

  2. Thanks for helping me ouit what i am trying to do is

     

    My dropdown list isalready being defined and i want to set that option as selected which is equal to the value being returned from the database

     

    this could be done via javascripting too but i am getting problems with both approach as i am not a pro.

     

    i tried to echo as selected on the returned value but it make that value appears twice in the list

     

    so kindly help.....

     

    Are... Are you serious?

  3. Not to mention that Java and JavaScript are not related at all....

     

    Lol yeah that was my first though.

     

    Sometimes, just sometimes, I can't tell the difference between a troll and an extremely ignorant person. No offense OP, no offense.

  4. I come across lots and lots of criticism across the net towards PHP and many of its axioms as well as implementations. How do you all feel about this? Do we agree that PHP, overall, is not a solid, dependable language? Do we disagree and argue that, with the right set of tools and knowledge, PHP is as good a language as any?

     

    Some examples of the hate I often see are on phpwtf.org. Although essentially all of it is avoidable, there are some things worth discussing (I think).

  5. It's AJAX just the same. A function is repeatedly called in the background that utilizes AJAX to check for updates (stuff that wasn't there the last time the function was called). It's probably something like every 2 or 3 seconds it's called (or maybe every second - I don't know just how much Facebook servers can handle but it's probably a lot more than I imagine).

  6. Lol.

     

    There's an extremely distinct difference between JavaScript and PHP (that which doesn't allow you to mix them).

     

    Try this:

     

    <script type="text/javascript">
    function dataInsert()
    {
    alert('TEST');
    }
    </script>
    
    <?php
    
    function timeCompare($tabletime)
    {
    global $result;
    global $q;
    $available = true;
    while ($row = mysql_fetch_array($result))
        {
    	$qtime = substr($row['date'], 11, 16);
    	if ($tabletime == $qtime)
    	{
    		echo "<td>TAKEN</td>";
    		$available = false;
    		break;
    	}
        }
    if ($available)
    {
    
    	echo "<td>";
    	echo "AVAILABLE - ";
    	echo '<input type=button name="book" value="  BOOK NOW   " onClick="javascript:dataInsert()"/>';             //This is supposed to call the function, and display the alert message
    	echo "</td>";
    }
    if (mysql_num_rows($result) != 0)
    {
    	mysql_data_seek($result,0);
    }
    }
    
    ?>

  7. <?php
    //Populates $gang variable
    $query = $db->execute("select * from gangs where `id`= '".$player->gang_id."'");
    
    if ($query->recordcount() == 0) {
        header("Location: ../your_gang/register.php");
    } else {
        $gang = $query->fetchrow();
    }
    ?>

  8. Don't do this:

     

    $result1            = $op->runsql("SELECT a.last_access FROM ".tbl_author." a WHERE a.id = '$userid'");
      if(mysql_num_rows($result1) > 0){
    while($row1 = $op->select($resul1t)){
    
    $last  =$row1['last_access'];
    if ($last < time() - (60*15))
    {  // 15 minutes cosideration
    
    $result = $op->runsql("UPDATE ".tbl_author." SET status = 1 WHERE id ='".$userid."'");
    }else{
    $result = $op->runsql("UPDATE ".tbl_author." SET status = 0 WHERE id ='".$userid."'");
    }
    
    } }

     

    I know I suggested it to you, but I'm tired and I wasn't thinking clearly. The above script will put a very serious strain on your server and MySQL Database(s). Instead, simply check the time when a user views another user on profile.php (or anywhere that online status is shown for a particular user).

     

  9. On the page before the page on which a user modifies a picture, store the current page in a session variable:

     

    $_SESSION['last_page'] = $_SERVER['PHP_SELF'];

     

    Then, on the page on which a user actually modifies a picture, after the modification is complete, call to header like this:

     

    header("Location: ".$_SESSION['last_page']);

  10. Hi Guys,

    I tried your code and the results are attached in a screen shot.  As you can see part of the code is placed in the input box and the rest of it after the input box.  I think what needs to be done is address the attributes of the input box which this code does not do.  I haven't the foggiest idea od how to do that.

     

    Thanks

    ahvceo

     

    Don't fill this name-already-in-use error message into an input box. Place it next to or above the input box.

  11. Something like that,,, but the progress bar on the bottom of my browser slowing gets to 100%,, really really slow.. and then does nothing.

     

     

    Lol, because you're infinitely redirecting. If you just keep calling to the Location header and redirecting to the page you're already on every time it loads, immediately, the page will just keep refreshing over and over again.

     

    You need to call to the Location header only in specific cases.

  12. In addition to the ENUM in your users table that stores online status, you'll need a field to store a UNIX timestamp of the time any given user last visited a page on your site: just update it, filling in time(), each time a user "goes somewhere" on your site, so to speak.

     

    Then, you'll need a script that runs on every page that runs through all users, and checks to see if a user's last updated time is less than time() - (60*15); if it is, set their online status to 0.

     

    Hope this helps: feel free to ask for clarifications on my above method.

  13. ok my register is like this $pass = md5($pass); how to not make it md5? could atleast someone help in this?

     

    I'm starting to believe you're trolling this board...

     

    Remove that line altogether, and md5 encryption will stop.

     

    Edit: Actually, I'm now positive this is some seriously hardcore trolling. I'm about to potentially violate TOS Rule #14: Can someone lock this? Daniel0 perhaps?

×
×
  • 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.