Jump to content

Northern Flame

Members
  • Posts

    816
  • Joined

  • Last visited

    Never

Everything 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. this should be under the PHP HELP section.... you can grab information from a page using cURL() if you know how to use it right, but it depends on what website you are trying to grab info from and what info you want.
  4. not all the time, but that is one of the benefits of GET
  5. Sorry, I have been looking in google for awhile and I barely found it, its array_product()
  6. 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)
  7. change these lines: $result = mysql_query($sql); $result2 = mysql_query($sql2); to $result = mysql_query($sql)or die(mysql_error()); $result2 = mysql_query($sql2)or die(mysql_error());
  8. 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++; } ?>
  9. 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>
  10. 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
  11. 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
  12. and make sure its someone you trust
  13. before re-connecting and re-selecting databases, use the mysql_close() function.
  14. 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.
  15. 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.
  16. with GET you can have different URLS that is easier for users to remember, like if you had a membership program you could have http://www.yourwebsite.com/users/username and that will also be seen by robots and if cached will be shown in search results. post is more for passing sensitive information through forms and such.
  17. depends on the application, what are you planning on building?
  18. so you mean you want to send the post variables to form.php if so, you can do that with cURL()
  19. 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
  20. try doing this: if (isset($_POST['submit'])){ in line 3
×
×
  • 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.