Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Community Answers

  1. benanamen's post in Finding a variable in an array was marked as the answer   
    You mean like this?
    $my_heros = [ 'Batman' => 0 , 'Superman' => 0 , 'Spiderman' => 0 , 'Hulk' => 0 ]; $my_heros['Batman'] = 10; $my_heros['Superman'] = 15; $my_heros['Hulk'] = 20; asort($my_heros);// Sorted by Points   echo '<pre>'; print_r($my_heros); echo '</pre>'; Result:
    [spiderman] => 0
    [batman] => 10
    [superman] => 15
    [Hulk] => 20
  2. benanamen's post in PDO: Problem with login system was marked as the answer   
    You see the problem now right? You are incorrectly expecting if ($row == 1. The var dump shows you what the result is which is an array of the result.
    Change the code to
    if ($row){ // do login stuff } else{ // login failed }
  3. benanamen's post in ON DUPLICATE KEY UPDATE - Positional Placeholders was marked as the answer   
    SOLVED. After some searching and RTFM I found the answer and learned something new. I needed to use something called the "VALUES(col_name)".
    Per the manual:
  4. benanamen's post in Best way to log someone out? php sessions was marked as the answer   
    It was not a personal attack so there's no reason to feel bad. If you're going to be a programmer you need to be able to handle people telling you about your code if it's not right. Study the code I gave you and this tutorial and you will be well on your way. https://phpdelusions.net/pdo
  5. benanamen's post in How to modify one element of an array on the fly. was marked as the answer   
    Simple enough...
    <?php $param = [ "fields" => "City|Price", "values" => "Las Vegas|$600,000", "template" => "similar_listings.php", "orderby" => "Price", "orderdir" => "DESC", "sort_type" => "LOCAL", "count" => 3, "masterdb" => 1, "get" => [ "sorteddir" => "DESC" ] ]; echo $param['values'] = str_replace('$', '', $param['values']);
  6. benanamen's post in multiple checkbox values selected from db was marked as the answer   
    Your real problem is your database design. You do not store multiple values in the same field. You need one more table that stores the post_id's and the related tag id's.
  7. benanamen's post in Listing all the files from folders and subfolders was marked as the answer   
    Step # 1: Go to google and search for "Please give me a solution step by step for listing all files (pdf) from folders and subfolders that are uploaded on my server".
    Step #2: Make an attempt at what find.
    Step #3: If you are still stuck, post your attempt on this forum and we will advise you.
  8. benanamen's post in Free SSL Certificates was marked as the answer   
    I use SSL for free. Simple and fast setup. I can create a new SSL Virtual host in about 2 minutes.
  9. benanamen's post in Need help getting mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given error. was marked as the answer   
    Problem is not solved. Where are you people constantly coming up with this same bad code over and over again? Pretty much everything you could do wrong here, you did.
    Save yourself troubles and start using PDO. It's how we code in 2017. https://phpdelusions.net/pdo
  10. benanamen's post in Parse error: syntax error, unexpected '$host_name' (T_VARIABLE) in /homepages/38/d597262079/htdocs/s/noosha/connect.php on line 2 was marked as the answer   
    You have a space in line 1. Use a proper IDE and you will see these simple mistakes.
    <? php
    Should be <?php
  11. benanamen's post in Help with php to display a list from a SQL Query was marked as the answer   
    NO!, You always select the specific column names you want. DO NOT SELECT *
    Modify this to use the results of your query
    <!DOCTYPE html> <html> <head> <title></title> </head> <body> <form action="<?= $_SERVER['SCRIPT_NAME'] ?>" method="post"> <select name="sort_by"> <option value="">Select Option</option> <?php $array = array('id' => 'ID', 'name' => 'Name', 'amt' => 'Amount', 'status_filter' => 'Status'); foreach ($array as $key => $value) { $selected = isset($_POST['sort_by']) && $_POST['sort_by'] == $key ? 'selected' : ''; echo "<option value='$key' $selected>$value</option>\n"; } ?> </select> <input name="submit" type="submit" value="Submit"> </form> </body> </html>
  12. benanamen's post in Run SQL Query via button click on user input was marked as the answer   
    Your query is not valid. More importantly you are using obsolete mysql code that has been completely removed from Php. You need to use PDO. https://phpdelusions.net/pdo
  13. benanamen's post in Datagrid suggestion was marked as the answer   
    You mean something like this?
  14. benanamen's post in if(trim($row->mysql_field == 0)) { Is this a valid construct? was marked as the answer   
    Forget the author. Just do (True example. Yours is a false example)
    If true
    if($row->mysql_field){ //Do something } This example is also in the manual. Couldn't find the page at the moment.
    if false (Your example)
    if(!$row->mysql_field){ //Do something }
  15. benanamen's post in Need help please was marked as the answer   
    Look at your first if. Your POST is wrong. $POST should be $_POST
  • 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.