Jump to content

benanamen

Members
  • Posts

    2,079
  • Joined

  • Last visited

  • Days Won

    41

Community Answers

  1. benanamen's post in error log in Laragon was marked as the answer   
    Easiest way is from the Laragon menu.
  2. benanamen's post in Webserver suggestions and replacement to Laragon was marked as the answer   
    For anyone following...
    I did a screen-share with the OP. The problem was missing files and files in the wrong place. I did a clean install of Laragon and installed (Not upgraded) Mysql 8. All is working.
  3. benanamen's post in Download MySQL 8.0.29 was marked as the answer   
    I wrote step by step instructions a few years ago in the Laragon forum on how to upgrade to Mysql8. I assume Laragon is the actual dev on your system and you are not trying to install Mysql outside of Laragon.

    You will need to register on the forum. See instructions here....
    https://forum.laragon.org/topic/2017/mysql-8-upgrade-instructions/2
  4. 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:
     
    Array
    (
    [spiderman] => 0
    [batman] => 10
    [superman] => 15
    [Hulk] => 20
    )
  5. 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 }
  6. 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:
     
     
    https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html
  7. 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
  8. 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']);
  9. 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.
  10. 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.
  11. 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.
  12. 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
  13. 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
  14. 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>
  15. 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
  16. benanamen's post in Datagrid suggestion was marked as the answer   
    You mean something like this?
     
    https://css-tricks.com/examples/DynamicOrderForm/
  17. 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 }
  18. 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
  19. benanamen's post in unexpected end of file was marked as the answer   
    You are missing the closing }
     
    There are other problems. You need to use prepared statements. You never insert user supplied data directly to the DB. Dont SELECT *. Specify the columns you want. You also do not need to manually close the connection. It closes automatically. It would appear your logic is flawed.
     
    You can't throw two query parameters into mysql like that. And don't create variables for no reason. I formatted your code so it is more readable but it still needs fixing aside from the missing bracket I put in.
     
    I would recommend you use PDO. https://phpdelusions.net/pdo
    <?php if (isset($_POST['choices']) && !empty($_POST['choices'])) { if ($_POST['choices'] == 'four') { //variables from form entered $username = $_POST['username']; $neptune = $_POST['neptune']; $email = $_POST['useremail']; //connect to the database $dbc = mysqli_connect('localhost', 'root', '', 'happygam_main') or die('Error connecting to MySQL server'); $check = mysqli_query($dbc, "select * from ballot where username='$username' and neptune='$neptune'"); $checkrows = mysqli_num_rows($check); if ($checkrows > 0) { echo "This combination of neptune and username has already been processed"; } else { //insert results from the form input in 2 rows one with neptune one without $query = "INSERT IGNORE INTO ballot(username, useremail, neptune) VALUES('$username', '$email', '$neptune')"; $query1 = "INSERT IGNORE INTO ballot(username, neptune) VALUES('$username', '$neptune')"; $result = mysqli_query($dbc, $query, $query1) or die('Error querying database.'); mysqli_close($dbc); } } } ?>
  20. benanamen's post in Can not use isset to fix undefined index was marked as the answer   
    Change 
    if (isset($_POST['submit']=="Sign Up")) To
    if ($_SERVER['REQUEST_METHOD'] == 'POST') You are also trying to use variables in your form without checking if those variables exist.
  21. benanamen's post in Header Vanishes if I remove LIMIT 1 was marked as the answer   
    Ok, now we are getting somewhere. Let's start from the beginning.
     
    You shouldn't be using sha256. You need to use password_hash.
     
    Line 13 should be if ($_SERVER['REQUEST_METHOD'] == 'POST') Depending on getting the name of a button to be submitted for your script to work can be problematic in certain instances.
     
    Do not SELECT *. Specify the exact columns you want.
     
    $_SERVER['PHP_SELF'] is vulnerable to an XSS Attack. Just leave the action out to submit to the same page.
     
    You need to kill the script at the header redirect.
    die(header("Location: index.php")); 
     
    You need to use prepared statements
     
    On the index page, there is no need for another query. You have already set the fname session on login. Just use it now.
     
    index.php 
    <?php session_start(); ?> <p>Hello <?= $_SESSION['fname'] ?> You are logged in as Admin!</p> I highly recommend you use PDO https://phpdelusions.net/pdo
  22. benanamen's post in help inserting into database was marked as the answer   
    You need to use prepared statements. You never ever send user supplied data directly to the database. Your code is just waiting for an SQL Injection Attack. Get rid of all those variables for nothing.  Turn on error reporting and check your logs.
     
    I suggest you use PDO instead of Mysqli
    https://phpdelusions.net/pdo
     
    * Good job on using if( $_SERVER['REQUEST_METHOD'] == 'POST')
  23. benanamen's post in PHP code stopped working was marked as the answer   
    Of course it's blank. All your doing is setting $error. The script is done by the time you get to this point. Think this through, I am sure you can figure out what needs to be changed.
     
     
            } else {
                $_SESSION['loggedIn'] = false;
                $error = "Invalid username and password!";
            }
     
     
    FYI: This is no kind of logging in code you should be using.
  24. benanamen's post in mysql_fetch_assoc return null values was marked as the answer   
    You have a handle of $row but are using $_row.
  25. benanamen's post in Hyperlink in PHP (harder than it sounds) was marked as the answer   
    Are you defining $content before here? Reason is you are doing dot equals. If it is not defined change .= to just =
     
    The image doesn't help. Where is $content first defined? Meaning where is content= without the period?
×
×
  • 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.