Jump to content

Search the Community

Showing results for tags 'if ()'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. Hi again, Freaks, hope you've all been well. I have what I would have considered a simple problem if not for the trouble it's giving me. I have the following bit -> <?php if(!$message) : ?> <h4>Leave a comment</h4> <?php else : ?> <div class='success'> <p class='bg-success text-center'>We have your comment and it will be added after approval</p> </div> <?php endif; ?> this code is obviously in the body of the page. At the top I have this -> <?php require("assets/initializations.php"); $post_obj = new Post($conn, $user); //simply increase #views per page load if(isset($_GET['post_id']) && !empty($_GET['post_id'])) { $id = $_GET['post_id']; $query = mysqli_query($conn, "SELECT * FROM news WHERE id=$id"); $row = mysqli_fetch_array($query); $category = $row['post_category']; $views = $row['num_views']; $views ++; mysqli_query($conn, "UPDATE news SET num_views='$views', time_stamp=NOW() WHERE id=$id"); //comment to db $message = false; if(isset($_POST['submit'])) { mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $comment_obj = new Comment($conn); if($comment_obj->addComment($id, $_POST['name'], $_POST['email'], $_POST['comment'])) { $message = true; } } } ?> Everything works fine except I can't get the body if statement to show anything other "Leave a Comment". The comment gets to the database but the success message won't show. I've tried this various ways before using this format. I assigned the $message up top and tried echoing it in the body. I then tried ternary style. Then I remembered that I had to do the same thing months ago when I made the registration form. So I decided to try that style here. The code from the register.php is this -> <?php if(!empty($errors)) : ?> <div class="errors"> <p class="bg-danger text-center"><?php echo implode( '</p><p class="bg-danger text-center">', $errors ); ?></p> </div> <?php elseif($sent) : $js_switch = true; ?> <div class="success"> <p class="bg-success">You've been successfully registered. Login and enjoy the network.</p> </div> <?php endif; ?> This code works great and is why I decided to do the same on my current issue, but nothing that I do gets "Leave a Comment" to change to the success message. Is there some obscure rule of PHP I've overlooked? I really can't figure out why the bit I'm working on now isn't working correctly like that bit I copied it from. Thanks for all responses
  2. Hi I am new to PHP and I am having an issue with a foreach loop combined with an if statement, basically the if statement is getting the data from the first result in the foreach but not getting the second result, I have tried implement a count by using a variable to iterate but it isnt working: Code as follows: foreach(findCustomAlerts($customerid) as $key=>$value){ echo "ID of cat : ".$rifdid = $value['Catid']."<br>"; echo "Visits required per day : ".$visitsneeded= $value['Visits required']."<br>"; } foreach(getTodaysVisits($device_id) as $rfid){ foreach($rfid as $key=> $read){ if($key ==$rifdid && $read < $visitsneeded) { echo"<br>". $key." has not visited enough"; } } } Ouput is : ID of cat : 5609 Visits required per day : 3 ID of cat : 23641 Visits required per day : 5 Array ( [rfid_id] => Array ( [23641] => 1 [5609] => 3 ) ). -------> this is the array data 23641 has not visited enough ----------------------------------------------- How can I get the loop to iterate to the next value?
  3. I am working on updating code to work in 5.4 php and am having some issues with IF statements and reaction IF(empty($var) = check if 0,empty or not set IF(isset($var)) = check if set (this has issues in 5.4 I am replacing but what is the best replacment) IF(!$var) = check not set IF($var) = Check if set IF($var1 <> $var2) = Replace with IF($var1 != $var2) Just trying to understand. I did not write all the code but am trying to standardize on a common format
  4. Hello I need to find a way to close loop outside if condition like below example if(escape($_POST['jobCategory']) != "all-categories" && escape($_POST['countryId']) == "all-countries"): $query = mysqli_query($dbConnection,"SELECT jobs.id, jobs.job_title, jobs.salary, jobs.employer_id, employers.employer_name, employers.employer_logo FROM jobs LEFT JOIN employers ON jobs.employer_id = employers.employer_id WHERE job_status = '".mysqli_real_escape_string($dbConnection,'Active')."' AND id IN (".mysqli_real_escape_string($dbConnection,$job_id_imploded).") "); while($row = mysqli_fetch_assoc($query)){ // Start Loop $job_id = $row['id']; $job_title = $row['job_title']; endif; <div class="job-title"> <a href="job_post.php?job_id=<?php echo htmlspecialchars($job_id) ?>" class="job-title-link"><?php echo htmlspecialchars($job_title); ?></a> </div> } // End Of Loop Gives me error HTTP ERROR 500
×
×
  • 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.