Jump to content

bh

Members
  • Posts

    238
  • Joined

  • Last visited

Posts posted by bh

  1. hi,

     

    heres an example:

     

    $sql = "SELECT * FROM content WHERE page = '$page'";
    $res = mysql_query($sql) or die (mysql_error());
    
    if (0 === mysql_num_rows($res))
    {
    // page not found
    // send a header and exit
    }
    
    while($row = mysql_fetch_assoc($res)){
    

  2. hi,

     

     

    The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

    so becouse not all user agent set this value, you have to check whether this property is exists or not. try to debug it (eg output the referer)

  3. Sorry for double posting but

     

    @ph are you saying i should have a seperate file that has the js in that has the prompt code in, i'm getting confused.

     

    If you have a small code its worthless. Rather enterprise level worth separate app and business logic. Your application with template system enhance readability, servicing... you can simply change templates (eg. other color schemes...), designers work easily on templates

  4. PHP already is a template engine.  Look at any decent MVC framework and how they handle their views.  All Smarty provides is additional overhead and an extra language you have to learn.  You're not gaining anything that you couldn't get with a well-planned PHP-only app.

     

    Yep, youre right. And popular frameworks has template system, yes. Imho its ugly cuz theres <?php ?> tags in your template. Extra language to learn at elementary level is almost nothing. Overhead at now with Smarty 3 (based on PHP 5 - 100% rewrite) also a bit (if you use eg APC its almost nothing to).

    But if you use smarty (and you choose the tiny overhead) youve got some extra feature which smarty add to you (block, functions, modifiers...).

     

  5. Yep, as i sad theres an other problem at the and of your code. Put a bracket after echo...

    echo ("
    <td align='center' height='30'><form name='myForm' method='post' action='event_details.php'><input type='hidden' name='event_id' value='" . $row["id"] . "'><input type='image' src='images/btn_event_details.jpg' align='absmiddle' height='30' alt='View Full Event Details'></form></td>
    </tr>
    </table>
    <br>");
    }

  6. Hi,

     

    you always get 0..10 rows:

    $sql="SELECT * from sp_users,sp_schools where sp_users.user_id=sp_schools.school_id ORDER BY school_name LIMIT 0, 10";

     

    Send the actual offset (now 0) and length (now 10) to the next page (if someone click next or previous) eg in a hidden input. At next page you can get

    your previous page's hidden inputs. After that you can calculate it (eg show the next 10 rows - set offset to 10)

  7. Hi,

     

    I guess your id column is an auto_increment col. So what you said its true, if you delete a row than the auto_inc value of the table doesnt change. But! its not a good idea to change those "gapped" ids - cuz maybe theres a reference to it. If your foreign keys are perfect (means CASCADES...) and theres everywhere, then you wont get error, but only this point, i think.

  8. If you start a transaction, that means you have an active transaction. You can finish your active transaction with a commit or a rollback. After you commited a transaction you cant rollback it.

    So start a transaction, check error, if theres an error rollback your transaction, else commit it.

     

    Some useable info: You cannot create a transaction on non-transaction tables (eg MyIsam), and you cannot rollback DDL statements.

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