Jump to content

cyberRobot

Moderators
  • Posts

    3,052
  • Joined

  • Last visited

  • Days Won

    27

Community Answers

  1. cyberRobot's post in "include('../db.php');" doesn't work was marked as the answer   
    If I'm reading everything correct, the "create" script is under todolist_demo > public_html > todo. The "create" script isn't able to find your db.php because the following line only goes up one level.
    include('../db.php'); Basically, you're telling "create" that db.php is in your public_html folder. You either need to use "../../db.php". Or I would actually recommend switching that line so it starts at the document root. I'm guessing "public_html" is your root folder. If that's the case, you could try the following:
    include $_SERVER['DOCUMENT_ROOT'] . '/../db.php';  
  2. cyberRobot's post in Error session variable not displaying message in another php file was marked as the answer   
    Just to make sure, for benanamen's suggestion, you should replace the following line:
    if(isset($_POST["submit"])) With the line below. Note that I removed the curly / smart quotes around POST.
    if($_SERVER['REQUEST_METHOD'] == 'POST') I would also add some sort of debug code to see if the if test is working. For example,
    if($_SERVER['REQUEST_METHOD'] == 'POST') { echo '<br>form submission detected'; Does the script display "form submission detected" after submitting the form? Also, if the script still doesn't work as you expect, please post your most recent code.
  3. cyberRobot's post in n00b - simple script to pull and show sql variable was marked as the answer   
    As Psycho was referring to, you can replace this
    $sql = "SELECT ID FROM thunderball  ORDER BY ID DESC LIMIT 1"; $rs = mysqli_query($connection,$sql); $row = mysqli_fetch_array($rs); $id =  $row['ID'];   With this $id = mysqli_insert_id($connection);   Note: that single line replaces all four lines. You don't need to run a separate query to get the ID of last record added. MySQL handles that for you.       If you output $id, you should get the ID you are looking for. And you should be able to change this $smsg = "Thunderball Event Created Successfully.";   To something like this $smsg = "Thunderball Event Created Successfully. Your ID is " . htmlentities($id);  
  4. cyberRobot's post in Making a News Website! Need help! was marked as the answer   
    Have you looked into building dynamic (aka database-driven) websites with PHP and MySQL? Basically, the information that needs to be displayed on multiple pages, like your headlines, articles, etc., would be stored in a database (eg MySQL). Then you create whatever page scripts are needed to display the information. For example, you would have one script for the home page which would query the database to pull the newest headlines. Each headline could be a clickable link that passes the article ID to another page script designed to display the article details. The details script would pull the article information from the database using the passed ID.
  5. cyberRobot's post in Why delete not working - CLASS.USER.PHP was marked as the answer   
    Have you checked the return value of $stmt->execute();? It should return true if the prepared query executes successfully.
     
    If it's returning false, PDO and MySQLi have methods for seeing the errors that are being thrown by MySQL.
     
    Side note: you'll want to look into binding variables into prepared queries. Using the raw value from variables, like $id, makes the query susceptible to SQL Injection Attacks.
  6. cyberRobot's post in Displaying multiple error messages was marked as the answer   
    You can do something like this:
    <?php if (isset($_POST['submit'])) {     function validate($key, $value)     {         $error = array();         switch ($key) {             case 'firstname':                 $error[$key] = (empty($value)) ? 'Putt Your Firstname' : '';                 break;             case 'lastname' :                 $error[$key] = (empty($value)) ? 'Putt Your Lastname'  : '';                 break;             //...         }         return $error;     }       // $arr = array('firstname', 'lastname', 'email', 'pass', 'confirmpass');       foreach ($_POST as $key => $value) {         $error = validate($key, $value);         echo $error[$key];     } } ?> The above code uses the ternary operator. More information can be found here:
    http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
     
     
    Side note: Put is spelled with one (1) "t". "Putt" is something else. 
  7. cyberRobot's post in Creating 'count' function as training - problem with multidimensional arrays was marked as the answer   
    You get that value because $b gets printed at the end of every function call. If you're looking for a running total, you would need to return $b.
    http://php.net/manual/en/functions.returning-values.php
  8. cyberRobot's post in Creating a link within PHP output from database was marked as the answer   
    Try changing this
    $output .= "Date: $date <br />Utility: $utility<br />Address: $address<br />Serial Number: <a href=\\'/dashboard-display?id='.$row['serialNumber'].''>$sn</a><br /><br />";   To this $output .= "Date: $date <br />Utility: $utility<br />Address: $address<br />Serial Number: <a href='/dashboard-display?id=".$row['serialNumber']."'>$sn</a><br /><br />";
  9. cyberRobot's post in comments spilling out of my comment box was marked as the answer   
    Does the box scale for normal words?
     
    If you are expecting strings like the ones shown in the screenshots, you could look into CSS' overflow property:
    https://developer.mozilla.org/en-US/docs/Web/CSS/overflow
  10. cyberRobot's post in PHP working differently in different browsers was marked as the answer   
    Are you trying to get the page to display "User Not Found" before the redirect happens? If so, you can see the example at the bottom of the following page:
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
     
     
    I think the issue is with the "User Not Found" text in the content attribute. Unless I missed something in the documentation, linked above, the value before the semi-colon needs to be a number.
     
    Side note: PHP has a function for redirecting the page. More information can be found here:
    http://php.net/manual/en/function.header.php
  11. cyberRobot's post in input fields are not showing up was marked as the answer   
    It looks like your form is created within the setassign3() function. Where is the function being called?
     
    Also note that $this is used for class methods. As far as I can tell, setassign3() is just a user-defined function.
  12. cyberRobot's post in Scripting for XFA forms was marked as the answer   
    For what it's worth, the following looks promising:
    http://help.adobe.com/en_US/livecycle/9.0/LiveCycle_Designer_Scripting_Basics.pdf
×
×
  • 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.