Jump to content

bh

Members
  • Posts

    238
  • Joined

  • Last visited

Everything posted by bh

  1. @silkfire: "to check an input to make sure it only consists"
  2. hi, had you about http://php.net/manual/en/book.pcre.php? what is the type of the input? float? than maybe http://www.php.net/manual/en/function.is-float.php
  3. 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)){
  4. and you want to get $_POST['file'] ??? are you sure? update: try to get $_FILES['file'] // var_dump($_FILES['file']);
  5. hi, 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)
  6. 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
  7. Hi, you should query in the minimal content u can. If your parts in anywhere in the body get the entiry body and run the search loop in it. If those in a div get that div... Anyway regexp is not a fast method. You can use str pos in a loop, with the handy offset paramterer.
  8. 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...).
  9. 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>"); }
  10. sry, i forgot the bracket: <tr>"); if ($row['cancel'] == 1) {
  11. Use template system (like Smarty) to do that. From PHP you can assing variable to your template. In your template you can use html, js, css and your application code will be separated from your presentation code.
  12. <tr>" if ($row['cancel'] == 1) { -> <tr>"; if ($row['cancel'] == 1) { And theres one more at the end of your code in echo statement. At the beginning of echo you dont use bracket, but at the end as finish you use it.
  13. Hi, heres the mysql manual mysql_manual_delete DELETE FROM answer WHERE Ans_Answer1 = 1 AND ...
  14. 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)
  15. Hi, you need a delimiter such as / preg_replace("/youtube/","test",$relatedVideo->watchURL);
  16. Hi, Heres the problem: $arr = $results[0]; Your $result variable doesnt have a 0 index (it doesnt exists). Check it before you get.
  17. Hi, mysql max_connection is a system variable, you can change it in the my.cnf file. Max connections means: Max-connections vs os: You can get the connections with process_list
  18. Hello, What is the type your NewsDate column?
  19. Hi, foreach($array as $key => $value) { if(preg_match("/^Acer/", $value)) { unset($array[$key]); } }
  20. Hi, use glob to read folders and files, and Zip to zipped it to an archive. To download the archive headers help you eg this github repo (index.php/force_download())
  21. bh

    Syntax Error

    Im a little confused. WHERE statement after the values?
  22. 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.
  23. Why TEXT type? Its unnecessary overhead when you filter your table. Why dont you use an INT type (use timestamp)?
  24. 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.