Jump to content

kenrbnsn

Staff Alumni
  • Posts

    8,234
  • Joined

  • Last visited

Everything posted by kenrbnsn

  1. Your best way of accomplishing this is via Javascript with AJAX. Ken
  2. Did you try using sessions? Ken
  3. Use sessions. At the start of your first script put <?php session_start(); ?> then right before the header() call, put <?php $_SESSION['url'] = $URL; $_SESSION['type'] = $type; ?> In the second script put <?php session_start(); $URL = $_SESSION['url']; $type = $_SESSION['type']; ?> Ken
  4. You should always validate all user input. At the very least use the mysql_real_escape_string() on any user inputs that are strings and that will be used in a mysql query. Ken
  5. Change <?php $run = mysql_query($constructx); ?> to <?php $run = mysql_query($constructx) or die("Problem with the query: $constructx<br>" . mysql_error()); ?> This should tell you the problem. Ken
  6. The quote symbols in this statement are wrong: <?php $query = "SELECT image FROM identification WHERE id = ‘$id’"; ?> You should be using single quotes: <?php $query = "SELECT image FROM identification WHERE id = '$id'"; ?> Ken
  7. Since you know the files that should be included in your script, the easiest way of doing this would be: <?php $allowed = array('list','of','permitted','files'); if (in_array($_GET['id'],$allowed) && file_exists("path/to/{$_GET['id']}") { include("path/to/{$_GET['id']}"); } else { // // abort mission... // } ?> Another way of circumventing the problem, is not to use the explicit file name in the parameter, but to use an index into an array that holds the allowed include files. Then you would have to check if the key exists in the file. Ken
  8. The "@" suppresses error messages and shouldn't be used. Ken
  9. How are you getting these strings? Please post your code. Ken
  10. Nope. According to the PHP Manual entry on variables: Ken
  11. Change your query to <?php $query = "SELECT user_id, AVG($column_name) as my_avg FROM table GROUP BY user_id"; ?> Then in your code you can do <?php $average = $row[' my_avg']; ?> Ken
  12. Functions should return a value to be used, they really shouldn't echo anything, try this instead: <?php function categories() { $tmp = array(); $tmp[] = '<table style="margin:20px;" width="100%">'; $tmp[] = '<tr>'; $tmp[] = '<td>'; $categories = mysql_query('select * from categories'); while ($rowCategory = mysql_fetch_array($categories)) { $tmp[] = "<a style='line-height:20px;' href='?category={$rowCategory['category_id']}'>{$rowCategory['category_name']}</a><br>"; } $tmp[] = '</td>'; $tmp[] = '</tr>'; $tmp[] = '</table>'; mysql_free_result($categories); return (implode("\n",$tmp) . "\n"); } ?> Then both echo examples should work. Ken
  13. What does the function categories look like. Please put your code between tags. Ken
  14. A query that looks like SELECT * FROM booking WHERE. 'clientName == 'Sam'' is not correct. Notice the "." after the WHERE and the single quote before the column name clientName and the extra single quote at the end. It should look like: SELECT * FROM booking WHERE clientName == 'Sam' You code to create the query is wrong. It should be <?php $input = "Sam"; $string = "clientName == '$input'"; $table_id = 'booking'; $query ="SELECT * FROM booking WHERE $string"; $test = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); ?> I added the "or die" clause for debugging purposes. Ken
  15. What's in the variable $raw_value? The explode() function returns an array. Please post your code between tags. Ken
  16. What are you trying to accomplish with this code? Since we're seeing only a small snippet of the script, we can't suggest a (possibly) better way. Ken
  17. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=327588.0
  18. Please post a few lines before this one. Ken
  19. You don't have to use a foreach loop at all, just use the implode() function: <?php $letters = array('a','b','c'); echo implode('<br />',$letters); ?> Ken
  20. kenrbnsn

    echo IF

    Here's a simpler way (and cleaner way) of doing this: <?php $tst = array('address_L1'=>'Update Address','intro'=>'About You','profile_image'=>'Add Profile Image','Nickname'=>'Add A Nickname'); $tmp = array(); foreach ($tst as $item => $txt) { if (empty($User[$item])) { $tmp[] = "<li><a href='#'>$txt</a></li>"; } } if (!empty($tmp)) { // if $tmp is not empty a least one of the items tested was empty echo" <div id='items_todo'> <h3>Members Info</h3><br/> <ul>"; echo implode("\n",$tmp) . "\n"; echo"</ul> </div>"; ?> Ken
  21. Please see this reply in another similar topic. It explains everything much better. Ken
  22. Another way: <?php $two = strtotime('+2 weeks'); $date = time(); while ($date <= $two) { echo date('l, F j, Y',$date) . "<br>"; $date += 86400; //86400 seconds in a day } ?> Ken
×
×
  • 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.