Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Everything posted by joel24

  1. a switch statement would be cleaner. <?php <form action="hwpositive.php" method="post"> Enter number: <input type="text" name="number" /> </form> $input = $_POST["number"]; if ($input<0) { echo "Please insert a positive number."; } else if ($input>1000) { echo "Please insert a number less than 1000."; } //else if ($input!=is_numeric) //need to put the variable is the function as follows, the ! reverses the function, so !is_numeric is if its false, and is_numeric is if its true. else if (!is_numeric($input)) { echo "Please insert a valid number."; } else { //for loop expressions must be enclosed in ( expr1; expr2; expr3 ), then the code to execute on each iteration in curly brackets for ($i; $i<=$_POST["number"]; $i++ { echo "Hello World"; } } ?>
  2. you've set error reporting to e_all? error_reporting(E_ALL); and try using copy() rather than move_uploaded_file() to see if that works to ensure its not a folder/file permissions problem. and then use file_exists(); to ensure the file exists i.e. if if (file_exists($_FILES['myfile']['tmp_name']) && copy($_FILES['myfile']['tmp_name'], $uploadFile)) { $statement = "insert into Profile_Photos (filename) values ('{$uploadFile}')"; echo "<P>".$statement; mysql_query($statement); echo "<P>".mysql_error(); [code=php:0] //change copy back to move_uploaded_file(); when you've completed debugging
  3. print what these lines echoing if (move_uploaded_file ($_FILES['myfile']['tmp_name'], $uploadFile)) { $statement = "insert into Profile_Photos (filename) values ('{$uploadFile}')"; echo "<P>".$statement; mysql_query($statement); echo "<P>".mysql_error();
  4. if the form is to update a single row in a database, you can have a hidden field of which you can set the value to the row's ID number using PHP. i.e. <form> <input type='text' name='test' /> <input type='hidden' value='<?php echo $theIDnumber; ?>' name='id' /> </form> or if you're updating several rows you can receive an array of $_POST values for several inputs rather than name='input1' name='input2' etc etc i.e. <?php //php to receive input if (isset($_POST['test']) && is_array($_POST['test']) { foreach ($_POST['test'] AS $key => $value) { echo "textbox $key - $value"; } } ?> <input type='text' name='test[]' /> <input type='text' name='test[]' /> <input type='text' name='test[]' /> <input type='text' name='test[]' /> found a quick tute at http://jetlogs.org/2007/07/19/passing-input-arrays-in-php
  5. have a column 'sticky', with 1 (on) or 0 (off) values. then have your order like so ORDER BY sticky DESC, p.post_time ASC *edit* make sure the default value for the column is 0
  6. As ManiacDan said, uploading the file and storing a path in mysql is much better as storing the binary data of the image in mysql, reading this and then displaying as an image puts a lot of unnecessary strain on the db/server.
  7. check your log files Then use a script to determine which parts of the script are taking the longest, i.e. to find faulty loops etc $start = microtime(); $duration = array(); $x = 0; //loop here while ($x < 15000) { $x++; } $duration[] = microtime() - $start; $start = microtime(); $x = 0; //loop here while ($x < 15000) { $x++; } $duration[] = microtime() - $start; foreach ($duration AS $key => $value) { echo "Section $key Duration: $value<br/>"; } and then use set_time_limit(), also checking what hte limit was set to
  8. you could use sus_getloadavg() to get the load average in the past 1, 5 and 15mins and use this to help determine which processes are overwhelming the server.
  9. you're passing the users id through $_GET, hence why it is easy for anyone to edit any other users profile. when the user logs in, you should set some session variables, userID would be one. Then when the user goes to the edit page, it will update the database where userID={$_SESSION['userID']} have a look here for a quick sessions tute http://www.tizag.com/phpT/phpsessions.php
  10. run this and post what it prints exit("select pov.products_options_values_name from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS . " po where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_values_id = pov.products_options_values_id and po.products_options_id = 1 and pov.language_id = '" . (int)$languages_id . "'");
  11. what is this tep_image() function you're calling? are you executing the database query to retrieve the $product_info array? try echo exit($product_info['product_image_2'])); [/url] and see what it prints.
  12. sorry, I mean automatically refresh the page each time it is loaded by the user. if you want it to automatically refresh like facebook etc, you'll need to use AJAX/jquery.
  13. javascript is executed on the client's machine and PHP is executed on the server machine before the pages are sent to the client/user. So yes PHP will edit the javascript and then once PHP has finished executed, sends it to the client
  14. stamp the current time? time(); returns current unix timestamp. or do you want to use the time in the sql query somewhere?
  15. if you're pulling the page's content from a database it will automatically refresh the page each time the database is updated... the cache won't affect this
  16. joel24

    time()

    date_default_timezone_set()
  17. had the same problem n wrote a little script that I include in every page, //timezone php putenv('TZ=Australia/Sydney'); //get offset, including daylight savings! $currentOffset = "+".(date("Z") / 60 / 60).":00"; //timezone mysql $update_tz = @mysql_query("SET time_zone = '$currentOffset'") or die(mysql_error());
  18. I'm sure you could create an association table rather than having a 'set' datatype. I've never use find_in_set though from what you've said it should work, just ensure you're executing it correctly. Have a look here and I'm sure you'll find something to guide you.
  19. depending on how you're levels are structured, you can use the same principal (the IN condition). you need to ensure you've got the IN conditions structured properly: WHERE field IN ('apple', 'pear', 'orange') i.e. //this should implode the $_POST['sports'] array into the proper structure; ('sport1', 'sport2', 'etc'). You'll need to check $_POST['sports'] is set with isset() $sports = "('" . implode("',", $_POST['sports']) . "')"; $levels = "('" . implode("',", $_POST['levels']) . "')"; $sql = "SELECT SQL_CALC_FOUND_ROWS a.ItemID, a.spec, a.description, a.sport, a.category, a.price, a.unit_qty, a.is_visible, a.AdminID, b.name, b.ItemID as catID, c.Name as nameSport, c.ItemID as sportID FROM purchase_request_category_item as a LEFT JOIN purchase_request_category as b ON b.itemID = a.category LEFT JOIN ro_school_sports as c ON c.ItemID = a.sport WHERE a.sport IN $sports AND a.level IN $levels AND a.AdminID = '".$dist."' GROUP BY a.ItemID, b.name, c.Name ORDER BY a.ItemID DESC LIMIT ". $start.",".$limit; it will then select a row where the sport is IN the sport conditions AND the level is in the level conditions; WHERE a.sport IN $sports AND a.level IN $levels
  20. have a look around, there are quite a few forum topics relating to the implementation of plugins on here and google. here's one
  21. you need to modify the CSS for the list (<li>) so that it displays bullets, default is numbered. list-style: circle; or list-style: image url(rarrara/img.jpg);
  22. as you probably know, the 'detail' link displays the address. That link is called by a javascript onclick function with a dynamic id at the end which calls the page. <a href="#73" onclick="javascript: window.open('79376.asp?id=375','Detail','width=400,height=300,left=0,top=0');">Detail</a> To lessen the server load, I would set up a database and then create a program to crawl educa.ch and use regular expressions to extract data from each url ('79376.asp?id=375', '79376.asp?id=324', etc) from the onclick function, then store the contents in a database, preferably sorted into corresponding fields; address, email etc. Then you would need to extract the address from that detail page, how you would go about separating the address from the other content I am unsure. A crafty regular expression may do the job, you could easily pull the email as it is an anchor link with href='mailto:email@email.com' I'm not experienced enough with regular expressions so you'll have to find someone who is. Good luck
  23. i would have an sql statement similar to this, though i'm sure there are less convoluted ways. Haven't tested it, i'll leave that up to you if (isset($_POST['multi_sport'])) { $where = " WHERE"; if (is_array($_POST['multi_sport'])) //have to test this if condition { $count = count($_POST['multi_sport']); $i = 0; foreach($_POST['multi_sport'] AS $sport) { //count $i++; //if more where conditions to come, add OR if ($i <= $count) { $or = " OR "; } else { $or = ''; } $where .= " SportField='$sport' $or"; } } } else { $where = ''; } $sql = "SELECT * FROM table1 t1 JOIN table2 t2 ON t1.field = t2.field $where"; ** EDIT ** make sure that your multi select is posting an array of values across an easier way... a foreach put the array of multi select sports into a structure like so $multiSports = '("sport1", "sport2", "sport3")'; $sql = "SELECT * FROM table WHERE sportsColumn IN $multiSports";
  24. To try and read 10,000 pages from an external source and search those pages for content will take up a lot of resources and time. What exactly are you trying to get from those pages?
×
×
  • 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.