Jump to content

Proletarian

Members
  • Posts

    97
  • Joined

  • Last visited

Posts posted by Proletarian

  1. Or you can pass the variable by reference so changes to the variable actually occur.

     

    <?php
    
    function replace_value(&$obj) // note the addition of the & before the variable, indicating it is not being passed by reference
    {
    if($obj==1)
    {
    $obj=2;
    }
    }
    
    $number = 1;
    replace_value($number);
    
    echo $number;
    ?>

  2. // I would probably change this line...
    if(false !== ($breakpoint = strpos($string, $break, $limit)))
    // to this...
    if ($breakpoint = strpos($string, $break, $limit))
    

     

    It's just a preference, I suppose, but it makes more sense to me; because, the first line made me think you were checking if it weren't true, but it's a double negative check, where the second line is an affirmative check to continue with the following block.

     

    Give this a test, though, just to be sure.

  3. Does this work instead?

     

    $query = mysql_query("UPDATE home SET welcometitle='$welcometitle', welcomesection='$welcomesection', infotitle='$infotitle', infosection='$infosection', videotitle='$videosection'");

  4. I prefer code that is commented. That way, whatever style used, I know how to understand what is written.

     

    Side note, I never thought to use break statements as "closing brackets" to the case "open bracket". I'll be trying it out to see whether it improves my ability to organize my switch statements.

  5. For the most straightforward code, you need to form query statements that do two things for each page request -

     

    1) A query statement with/with-out the WHERE clause that will be used to find the total number of matching rows.

     

    2) The query statement from step #1 with the addition of a LIMIT clause on the end to get the actual rows for the requested page number.

     

    I'm sorry. Is there some reason you suggest running the same query twice instead of using SQL_CALC_FOUND_ROWS and SELECT FOUND_ROWS()? I mean, returning all those rows, twice, is very inefficient. At least, just use a SELECT COUNT() instead of selecting all the data. Did I miss something there?

     

    He's suggesting running two different queries. You need to know how many rows you're working with -- and which rows within a certain range you're working with -- before you can even start assembling the page.

  6. Not sure.

     

    SO you're saying this ONLY works on the server that I maintain the website on? 

    And the machine in my bedroom probably won't recognize it?

     

    Whichever server you are using, remove or local, is that server set up for server-side includes? I ask this question because the method you are using is a server-side include method and in order for it to work relies on the server being set up for it.

  7. I know i must do it because i don't have an active connection but i don't get why, i don't know what $con is equal to or why is it important

     

    According to this website: http://www.php.net/manual/en/function.mysql-connect.php

     

    Return Values: Returns a MySQL link identifier on success or FALSE on failure.

     

    mysql_connect() returns a mysql link identifier which is used to identify the connection you have opened with the database. You use this link identifier to determine whether your connection was successful and which connection in particular you are working with.

  8. Isn't that what I did.

    Are you trying to be a wiseguy and waste my time, or do you have an actual solution to suggest to improve my code?  If so, please POST IT!

     

    I'm not going to write code for you, sorry. If you already did it, then this topic is finished.

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