Jump to content

Northern Flame

Members
  • Posts

    816
  • Joined

  • Last visited

    Never

Posts posted by Northern Flame

  1. oh you dont want it to change anything?

     

    try this then:

     

    }
    if(!empty($_POST['hideemail']))
    {
    mysql_query("UPDATE $user 
    SET show_email = '1' 
    WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error());
    }
    echo "Settings Saved";
    }
    

  2. if(isset($_POST['hideemail']) == 0)
    

     

    that line makes no sense.

     

    try:

     

    }
    if(empty($_POST['hideemail']))
    {
    mysql_query("UPDATE $user 
    SET show_email = '0' 
    WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error());
    }
    else
    {
    mysql_query("UPDATE $user 
    SET show_email = '1' 
    WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error());
    }
    echo "Settings Saved";
    }
    

  3. Using $p directly instead of $_GET['p'] will only work if your PHP settings for register_globals is on (which is not safe).

     

    I think doing something like this will be a lot safer:

    <?php
    
    // Start a session
    session_start();
    
    $page = $_GET['p'] . '.php';
    
    if (file_exists($page))
    include $page;
    else 
    include 'home.php';
    
    ?>

     

    yes that would be a lot safer because the first

    method is extremely easy to hack

    And if you want to go the extra mile for security, also check if user inputs .. (disable include for parent directories).

  4. is there a function that multiplies the values inside an array?

    I know of array_sum(), and I want to know if theres something like

    that, but instead of adding them, it multiplies them

    (If not, I can create one for myself, but why create one if theres already

    a pre-defined one)

  5. try this (and if it doesnt work show me your error messages):

     

    <?php 
    
    mysql_connect("localhost","sgd","xxx"); 
    
    mysql_select_db("xxx") or die("Unable to select database");
    
    $art = $_GET['id'];
    $sql = "SELECT * FROM items WHERE id=$art";
    
    $result = mysql_query($sql);
    $num_rows = mysql_num_rows($result);
    if($num_rows == 0) {
    echo "No results please try a different <a href=asearch.html>search</a>.";
    } else {
    while($row = mysql_fetch_array($result)) {
    $code1 = $row['code1']; 
    $code2 = $row['code2'];
    }
    }
    
    mysql_close();
    
    mysql_connect("localhost","xxx","xxx"); 
    
    mysql_select_db("xxx") or die("Unable to select database"); 
    
    $sql = "SELECT * FROM `$code1 by $code2` ORDER BY id DESC LIMIT 3";
    
    $result = mysql_query($sql) or die(mysql_error());
    
    $num_rows = mysql_num_rows($result);
    if($num_rows == 0) {
    echo "";
    } else {
    $CommAuth = array();
    $Comment = array();
    $horde = array();
    $title = array();
    
    while($row = mysql_fetch_assoc($result)) {
    $CommAuth[] .= $row['name']; 
    $Comment[] .= $row['message'];
    $horde[] .= $row['horde'];
    $title[] .= $row['title'];
    }
    }
    
    mysql_close();
    
    mysql_connect("localhost","xxx","xxx"); 
    
    mysql_select_db("xxx") or die("Unable to select database");
    
    $sql2 = "SELECT * FROM ac_users WHERE username='$title' LIMIT 3";
    
    $result2 = mysql_query($sql2);
    $num_rows2 = mysql_num_rows($result2);
    if($num_rows2 == 0) {
    echo "No results please try a different <a href=reports.php>search 2</a>.";
    } else {
    $CommAvatar = array();
    while($row2 = mysql_fetch_array($result2)) {
    $CommAvatar[] .= $row2['avatar']; 
    }
    }
    $count = 0;
    foreach ($CommAuth as $value){
    
    print "<div id=\"comment\">
    <img src=\"/avatar/{$CommAvatar[$count]}\" width=\"56\" height=\"56\" class=\"comment_photo\" />
    <div id=\"comment_header\"><span class=\"comment_author\"> {$value} </span><span class=\"comment_wrote\">wrote...</span><span class=\"comment_stars\"><img src=\"stars_5.png\"/></span></div>
    <div class=\"comment_text\">{$Comment[$count]}</div>
    <div id=\"comment_footer\"><span class=\"comment_delete\">Report | Comment on {$value} Profile | Message {$value}</span></div>
    </div>";
    $count++;
    }
    ?>
    

  6. you can do something like:

     

    <script type="text/javascript">
    function checkFields(){
    var website = document.forms['myForm'].website.value;
    var homepage = document.forms['myForm'].homepage.value;
    var duration = document.forms['myForm'].duration.value;
    
    if(website == ""){
    website = 0;
    } else{
    website = 4;
    }
    
    if(homepage == ""){
    homepage = 0;
    } else{
    homepage = 20;
    }
    
    if(duration == ""){
    duration = 0;
    }
    
    var total_value = website + homepage + duration;
    }
    
    // then on calculate() do something like this:
    function calculate(){
    var total = 100; // enter whatever you want the total to be
    checkFields();
    var new_total = total - total_value;
    document.getElementById("showNewCalculations").innerHTML=new_total;
    }
    </script>
    <form name="myForm">
    <!--
    put your form here
    -->
    Total: <span id="showNewCalculations"></span>
    </form>
    

  7. yup thats pretty much how you would do it,

    although $SESSION[userlevel] should be $_SESSION[userlevel]

    if you're using php, which im guessing you are.

     

    And again (just nitpicking here) that would actually be $_SESSION['userlevel']

     

     

    LOL i didn't even notice that! oops!

     

    and $_SESSION stores session variables as an array,

    you can read more about it here:

    http://www.tizag.com/phpT/phpsessions.php

     

    or just to a google search on PHP and $_SESSION

  8. So if you don't use Classes, what would you use?

    Is classes the most efficient way of coding?

     

    then you would just use the regular method of coding.

     

    if you're going to have A LOT of code in one script

    then I would recommend using classes because it will

    help you organize your code and easily re-call functions

    that were established previously.

     

    as for efficiency,

    its pretty much the same thing,

    I mean I can code the exact same thing without

    classes that could with classes.

    but if its going to be a big file, i prefer classes to

    help me better organize my code

  9. Get it checked for Security Holes, and try to get another coder to review the code. (Make sure he is better than the current one).

     

     

     

    and make sure its someone you trust  ;)

  10. im not sure if theres a way to really check this because most of the time

    there is room for improvement. no one is perfect and no code is perfect.

    all you can really do is keep learning and advancing your skills to help

    improve your scripts.

  11. well as far as using classes (or OOP)

    its not really something thats "better" or "worse"

    but just a different style of coding.

    some people feel more comfortable coding using

    OOP and others don't. It's really up to you.

  12. thats not a PHP question this is an HTML question,

     

    and as far as hiding the right side scroll bar,

    im not too sure how,

    maybe just make scrolling="auto" and make the

    iframe height longer so that theres no need for

    the right side scroll

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