PHP Mad Libs with OOP and SQLHow to properly use OOP in PHP with formsProperly storing error messages and displaying them with OOPHow is OOP achieved with configuration files in PHP?Adventure game player using public fields instead of getters and settersCity and District class examples for teaching OOP in PHPGetting and posting data use PHP OOP and MySQLiFirst Memory Game with PyQt and OOPPHP OOP registration with User class and singleton Database classusing $_POST array to prepare PDO statement with variablesPhp how to properly connect functions with pagination

Copenhagen passport control - US citizen

If Manufacturer spice model and Datasheet give different values which should I use?

Do airline pilots ever risk not hearing communication directed to them specifically, from traffic controllers?

Japan - Plan around max visa duration

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

A function which translates a sentence to title-case

Set-theoretical foundations of Mathematics with only bounded quantifiers

Can a German sentence have two subjects?

Is it possible to do 50 km distance without any previous training?

Download, install and reboot computer at night if needed

How to report a triplet of septets in NMR tabulation?

Chess with symmetric move-square

What is the command to reset a PC without deleting any files

What do you call a Matrix-like slowdown and camera movement effect?

Motorized valve interfering with button?

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

How to make payment on the internet without leaving a money trail?

What are these boxed doors outside store fronts in New York?

Is Social Media Science Fiction?

Why is "Reports" in sentence down without "The"

TGV timetables / schedules?

I see my dog run

Patience, young "Padovan"

Why are only specific transaction types accepted into the mempool?



PHP Mad Libs with OOP and SQL


How to properly use OOP in PHP with formsProperly storing error messages and displaying them with OOPHow is OOP achieved with configuration files in PHP?Adventure game player using public fields instead of getters and settersCity and District class examples for teaching OOP in PHPGetting and posting data use PHP OOP and MySQLiFirst Memory Game with PyQt and OOPPHP OOP registration with User class and singleton Database classusing $_POST array to prepare PDO statement with variablesPhp how to properly connect functions with pagination






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1












$begingroup$


I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the page as a Mad lib (along with the rest of the DB).



I was hoping someone could review my source and let me know how to properly use the setters and getters, right now I think my code is just using POST to pass the user entered data to the method?? But if I take it out, it doesn't work anymore.



Basically I'm pretty lost right now and would appreciate any and all advice on how I can improve/fix this code. Right now it does work (including insertion and query of DB), but i'm not sure if I did It properly.



General guidelines Im following to covert to OOP (Inside Madlibs Class):



  • Create instance vars for holding a noun, verb, adjective, adverb, and story


  • Create getters and setters for all instance vars


  • Create method for inserting the new instance vars into DB


  • Create method for querying the stories that returns a results set newest to oldest


  • Create a method that takes the results set (from the query) as an argument, and returns the results onto page


Madlibs Class Code:



<?php
class MadLibs
private $noun; // String
private $verb; // String
private $adjective; // String
private $adverb; // String
private $story; // String - entire madlib story

// Getters
public function getNoun()
return $this->noun;


public function getVerb()
return $this->verb;


public function getAdjective()
return $this->adjective;


public function getAdverb()
return $this->adverb;


public function getStory()
return $this->story;



// Setters
public function setNoun($noun)
$this->noun = $noun;


public function setVerb($verb)
$this->verb = $verb;


public function setAdjective($adjective)
$this->adjective = $adjective;


public function setAdverb($adverb)
$this->adverb = $adverb;


public function setStory($story)
$this->story = $story;



// method for inserting the new properties into mad libs database table
public function insertMadLibs($noun, $verb, $adjective, $adverb, $story)
$story = "Have you seen the $adjective $noun? They got up and started to $verb $adverb!";

$dbc = mysqli_connect('localhost', 'root', '', 'project1')
or die('Error connecting to DB');

$query = "INSERT INTO Madlibs (id, noun, verb, adjective, adverb, story, dateAdded)" .
"VALUES (0, '$noun', '$verb', '$adjective', '$adverb', '$story', NOW())";

$result = mysqli_query($dbc, $query)
or die('Error querying DB');

mysqli_close($dbc);

echo '<span id="success">Success!</span>';



// method for querying the stories that return results set newest to oldest
public function fetchStory()
$dbc = mysqli_connect('localhost', 'root', '', 'project1')
or die('Error connecting to DB.');

$query = "SELECT * FROM Madlibs ORDER BY dateAdded DESC";

$result = mysqli_query($dbc, $query)
or die('Error querying DB.');

mysqli_close($dbc);

return $result;



// method that takes the results set (from the query) as an argument, and returns the results in a formatted HTML table
public function displayStory($result)
$dbc = mysqli_connect('localhost', 'root', '', 'project1')
or die('Error connecting to DB.');

while ($row = mysqli_fetch_array($result))
echo '<div id="comments"><p>Have you seen the <b>' . $row['adjective'] . ' ' . $row['noun'] . '</b>? <br />';
echo 'They got up and started to <b>' . $row['verb'] . ' ' . $row['adverb'] . '</b>! </p>';
echo '<span id="footer">Date: ' . $row['dateAdded'] . '</span></div>';


mysqli_close($dbc);



?>


index file where calls are made:



<!DOCTYPE html>
<html>

<head>
<title>Mad libs</title>
<link rel="stylesheet" href="styles.css" type="text/css" />
</head>

<body>

<?php
require_once('MadLibs.php');

$mad_libs = new MadLibs();

$mad_libs->setNoun($_POST['noun']);
$mad_libs->setVerb($_POST['verb']);
$mad_libs->setAdjective($_POST['adjective']);
$mad_libs->setAdverb($_POST['adverb']);

// How do I remove these and still have the program function??
// Get entered info form form
$noun = $_POST['noun'];
$verb = $_POST['verb'];
$adjective = $_POST['adjective'];
$adverb = $_POST['adverb'];

if (isset($_POST['submit']))
if ( (!empty($noun)) && (!empty($verb)) && (!empty($adjective)) && (!empty($adverb)) )
$mad_libs->insertMadLibs($noun, $verb, $adjective, $adverb, $story);
else
echo '<span id="error">Please fill out all fields!</span>';



?>

<div id="wrapper">

<h1>Mad Libs</h1>

<hr>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="noun">Enter a <b>Noun</b>: </label>
<input type="text" name="noun" id="noun" class="input" value="<?php echo $noun; ?>"/>
<br />

<label for="verb">Enter a <b>Verb</b> (Present Tense): </label>
<input type="text" name="verb" id="verb" class="input" value="<?php echo $verb; ?>"/>
<br />

<label for="adjective">Enter an <b>Adjective</b>: </label>
<input type="text" name="adjective" id="adjective" class="input" value="<?php echo $adjective; ?>"/>
<br />

<label for="adverb">Enter an <b>Adverb</b>: </label>
<input type="text" name="adverb" id="adverb" class="input" value="<?php echo $adverb; ?>"/>
<br />

<input name="submit" id="submit" type="submit" value="Submit"/>
</form>

</div>

<?php
$result = $mad_libs->fetchStory();
$mad_libs->displayStory($result);
?>

</body>

</html>









share|improve this question









New contributor




jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$


















    1












    $begingroup$


    I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the page as a Mad lib (along with the rest of the DB).



    I was hoping someone could review my source and let me know how to properly use the setters and getters, right now I think my code is just using POST to pass the user entered data to the method?? But if I take it out, it doesn't work anymore.



    Basically I'm pretty lost right now and would appreciate any and all advice on how I can improve/fix this code. Right now it does work (including insertion and query of DB), but i'm not sure if I did It properly.



    General guidelines Im following to covert to OOP (Inside Madlibs Class):



    • Create instance vars for holding a noun, verb, adjective, adverb, and story


    • Create getters and setters for all instance vars


    • Create method for inserting the new instance vars into DB


    • Create method for querying the stories that returns a results set newest to oldest


    • Create a method that takes the results set (from the query) as an argument, and returns the results onto page


    Madlibs Class Code:



    <?php
    class MadLibs
    private $noun; // String
    private $verb; // String
    private $adjective; // String
    private $adverb; // String
    private $story; // String - entire madlib story

    // Getters
    public function getNoun()
    return $this->noun;


    public function getVerb()
    return $this->verb;


    public function getAdjective()
    return $this->adjective;


    public function getAdverb()
    return $this->adverb;


    public function getStory()
    return $this->story;



    // Setters
    public function setNoun($noun)
    $this->noun = $noun;


    public function setVerb($verb)
    $this->verb = $verb;


    public function setAdjective($adjective)
    $this->adjective = $adjective;


    public function setAdverb($adverb)
    $this->adverb = $adverb;


    public function setStory($story)
    $this->story = $story;



    // method for inserting the new properties into mad libs database table
    public function insertMadLibs($noun, $verb, $adjective, $adverb, $story)
    $story = "Have you seen the $adjective $noun? They got up and started to $verb $adverb!";

    $dbc = mysqli_connect('localhost', 'root', '', 'project1')
    or die('Error connecting to DB');

    $query = "INSERT INTO Madlibs (id, noun, verb, adjective, adverb, story, dateAdded)" .
    "VALUES (0, '$noun', '$verb', '$adjective', '$adverb', '$story', NOW())";

    $result = mysqli_query($dbc, $query)
    or die('Error querying DB');

    mysqli_close($dbc);

    echo '<span id="success">Success!</span>';



    // method for querying the stories that return results set newest to oldest
    public function fetchStory()
    $dbc = mysqli_connect('localhost', 'root', '', 'project1')
    or die('Error connecting to DB.');

    $query = "SELECT * FROM Madlibs ORDER BY dateAdded DESC";

    $result = mysqli_query($dbc, $query)
    or die('Error querying DB.');

    mysqli_close($dbc);

    return $result;



    // method that takes the results set (from the query) as an argument, and returns the results in a formatted HTML table
    public function displayStory($result)
    $dbc = mysqli_connect('localhost', 'root', '', 'project1')
    or die('Error connecting to DB.');

    while ($row = mysqli_fetch_array($result))
    echo '<div id="comments"><p>Have you seen the <b>' . $row['adjective'] . ' ' . $row['noun'] . '</b>? <br />';
    echo 'They got up and started to <b>' . $row['verb'] . ' ' . $row['adverb'] . '</b>! </p>';
    echo '<span id="footer">Date: ' . $row['dateAdded'] . '</span></div>';


    mysqli_close($dbc);



    ?>


    index file where calls are made:



    <!DOCTYPE html>
    <html>

    <head>
    <title>Mad libs</title>
    <link rel="stylesheet" href="styles.css" type="text/css" />
    </head>

    <body>

    <?php
    require_once('MadLibs.php');

    $mad_libs = new MadLibs();

    $mad_libs->setNoun($_POST['noun']);
    $mad_libs->setVerb($_POST['verb']);
    $mad_libs->setAdjective($_POST['adjective']);
    $mad_libs->setAdverb($_POST['adverb']);

    // How do I remove these and still have the program function??
    // Get entered info form form
    $noun = $_POST['noun'];
    $verb = $_POST['verb'];
    $adjective = $_POST['adjective'];
    $adverb = $_POST['adverb'];

    if (isset($_POST['submit']))
    if ( (!empty($noun)) && (!empty($verb)) && (!empty($adjective)) && (!empty($adverb)) )
    $mad_libs->insertMadLibs($noun, $verb, $adjective, $adverb, $story);
    else
    echo '<span id="error">Please fill out all fields!</span>';



    ?>

    <div id="wrapper">

    <h1>Mad Libs</h1>

    <hr>

    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <label for="noun">Enter a <b>Noun</b>: </label>
    <input type="text" name="noun" id="noun" class="input" value="<?php echo $noun; ?>"/>
    <br />

    <label for="verb">Enter a <b>Verb</b> (Present Tense): </label>
    <input type="text" name="verb" id="verb" class="input" value="<?php echo $verb; ?>"/>
    <br />

    <label for="adjective">Enter an <b>Adjective</b>: </label>
    <input type="text" name="adjective" id="adjective" class="input" value="<?php echo $adjective; ?>"/>
    <br />

    <label for="adverb">Enter an <b>Adverb</b>: </label>
    <input type="text" name="adverb" id="adverb" class="input" value="<?php echo $adverb; ?>"/>
    <br />

    <input name="submit" id="submit" type="submit" value="Submit"/>
    </form>

    </div>

    <?php
    $result = $mad_libs->fetchStory();
    $mad_libs->displayStory($result);
    ?>

    </body>

    </html>









    share|improve this question









    New contributor




    jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      1












      1








      1





      $begingroup$


      I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the page as a Mad lib (along with the rest of the DB).



      I was hoping someone could review my source and let me know how to properly use the setters and getters, right now I think my code is just using POST to pass the user entered data to the method?? But if I take it out, it doesn't work anymore.



      Basically I'm pretty lost right now and would appreciate any and all advice on how I can improve/fix this code. Right now it does work (including insertion and query of DB), but i'm not sure if I did It properly.



      General guidelines Im following to covert to OOP (Inside Madlibs Class):



      • Create instance vars for holding a noun, verb, adjective, adverb, and story


      • Create getters and setters for all instance vars


      • Create method for inserting the new instance vars into DB


      • Create method for querying the stories that returns a results set newest to oldest


      • Create a method that takes the results set (from the query) as an argument, and returns the results onto page


      Madlibs Class Code:



      <?php
      class MadLibs
      private $noun; // String
      private $verb; // String
      private $adjective; // String
      private $adverb; // String
      private $story; // String - entire madlib story

      // Getters
      public function getNoun()
      return $this->noun;


      public function getVerb()
      return $this->verb;


      public function getAdjective()
      return $this->adjective;


      public function getAdverb()
      return $this->adverb;


      public function getStory()
      return $this->story;



      // Setters
      public function setNoun($noun)
      $this->noun = $noun;


      public function setVerb($verb)
      $this->verb = $verb;


      public function setAdjective($adjective)
      $this->adjective = $adjective;


      public function setAdverb($adverb)
      $this->adverb = $adverb;


      public function setStory($story)
      $this->story = $story;



      // method for inserting the new properties into mad libs database table
      public function insertMadLibs($noun, $verb, $adjective, $adverb, $story)
      $story = "Have you seen the $adjective $noun? They got up and started to $verb $adverb!";

      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB');

      $query = "INSERT INTO Madlibs (id, noun, verb, adjective, adverb, story, dateAdded)" .
      "VALUES (0, '$noun', '$verb', '$adjective', '$adverb', '$story', NOW())";

      $result = mysqli_query($dbc, $query)
      or die('Error querying DB');

      mysqli_close($dbc);

      echo '<span id="success">Success!</span>';



      // method for querying the stories that return results set newest to oldest
      public function fetchStory()
      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB.');

      $query = "SELECT * FROM Madlibs ORDER BY dateAdded DESC";

      $result = mysqli_query($dbc, $query)
      or die('Error querying DB.');

      mysqli_close($dbc);

      return $result;



      // method that takes the results set (from the query) as an argument, and returns the results in a formatted HTML table
      public function displayStory($result)
      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB.');

      while ($row = mysqli_fetch_array($result))
      echo '<div id="comments"><p>Have you seen the <b>' . $row['adjective'] . ' ' . $row['noun'] . '</b>? <br />';
      echo 'They got up and started to <b>' . $row['verb'] . ' ' . $row['adverb'] . '</b>! </p>';
      echo '<span id="footer">Date: ' . $row['dateAdded'] . '</span></div>';


      mysqli_close($dbc);



      ?>


      index file where calls are made:



      <!DOCTYPE html>
      <html>

      <head>
      <title>Mad libs</title>
      <link rel="stylesheet" href="styles.css" type="text/css" />
      </head>

      <body>

      <?php
      require_once('MadLibs.php');

      $mad_libs = new MadLibs();

      $mad_libs->setNoun($_POST['noun']);
      $mad_libs->setVerb($_POST['verb']);
      $mad_libs->setAdjective($_POST['adjective']);
      $mad_libs->setAdverb($_POST['adverb']);

      // How do I remove these and still have the program function??
      // Get entered info form form
      $noun = $_POST['noun'];
      $verb = $_POST['verb'];
      $adjective = $_POST['adjective'];
      $adverb = $_POST['adverb'];

      if (isset($_POST['submit']))
      if ( (!empty($noun)) && (!empty($verb)) && (!empty($adjective)) && (!empty($adverb)) )
      $mad_libs->insertMadLibs($noun, $verb, $adjective, $adverb, $story);
      else
      echo '<span id="error">Please fill out all fields!</span>';



      ?>

      <div id="wrapper">

      <h1>Mad Libs</h1>

      <hr>

      <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      <label for="noun">Enter a <b>Noun</b>: </label>
      <input type="text" name="noun" id="noun" class="input" value="<?php echo $noun; ?>"/>
      <br />

      <label for="verb">Enter a <b>Verb</b> (Present Tense): </label>
      <input type="text" name="verb" id="verb" class="input" value="<?php echo $verb; ?>"/>
      <br />

      <label for="adjective">Enter an <b>Adjective</b>: </label>
      <input type="text" name="adjective" id="adjective" class="input" value="<?php echo $adjective; ?>"/>
      <br />

      <label for="adverb">Enter an <b>Adverb</b>: </label>
      <input type="text" name="adverb" id="adverb" class="input" value="<?php echo $adverb; ?>"/>
      <br />

      <input name="submit" id="submit" type="submit" value="Submit"/>
      </form>

      </div>

      <?php
      $result = $mad_libs->fetchStory();
      $mad_libs->displayStory($result);
      ?>

      </body>

      </html>









      share|improve this question









      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the page as a Mad lib (along with the rest of the DB).



      I was hoping someone could review my source and let me know how to properly use the setters and getters, right now I think my code is just using POST to pass the user entered data to the method?? But if I take it out, it doesn't work anymore.



      Basically I'm pretty lost right now and would appreciate any and all advice on how I can improve/fix this code. Right now it does work (including insertion and query of DB), but i'm not sure if I did It properly.



      General guidelines Im following to covert to OOP (Inside Madlibs Class):



      • Create instance vars for holding a noun, verb, adjective, adverb, and story


      • Create getters and setters for all instance vars


      • Create method for inserting the new instance vars into DB


      • Create method for querying the stories that returns a results set newest to oldest


      • Create a method that takes the results set (from the query) as an argument, and returns the results onto page


      Madlibs Class Code:



      <?php
      class MadLibs
      private $noun; // String
      private $verb; // String
      private $adjective; // String
      private $adverb; // String
      private $story; // String - entire madlib story

      // Getters
      public function getNoun()
      return $this->noun;


      public function getVerb()
      return $this->verb;


      public function getAdjective()
      return $this->adjective;


      public function getAdverb()
      return $this->adverb;


      public function getStory()
      return $this->story;



      // Setters
      public function setNoun($noun)
      $this->noun = $noun;


      public function setVerb($verb)
      $this->verb = $verb;


      public function setAdjective($adjective)
      $this->adjective = $adjective;


      public function setAdverb($adverb)
      $this->adverb = $adverb;


      public function setStory($story)
      $this->story = $story;



      // method for inserting the new properties into mad libs database table
      public function insertMadLibs($noun, $verb, $adjective, $adverb, $story)
      $story = "Have you seen the $adjective $noun? They got up and started to $verb $adverb!";

      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB');

      $query = "INSERT INTO Madlibs (id, noun, verb, adjective, adverb, story, dateAdded)" .
      "VALUES (0, '$noun', '$verb', '$adjective', '$adverb', '$story', NOW())";

      $result = mysqli_query($dbc, $query)
      or die('Error querying DB');

      mysqli_close($dbc);

      echo '<span id="success">Success!</span>';



      // method for querying the stories that return results set newest to oldest
      public function fetchStory()
      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB.');

      $query = "SELECT * FROM Madlibs ORDER BY dateAdded DESC";

      $result = mysqli_query($dbc, $query)
      or die('Error querying DB.');

      mysqli_close($dbc);

      return $result;



      // method that takes the results set (from the query) as an argument, and returns the results in a formatted HTML table
      public function displayStory($result)
      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB.');

      while ($row = mysqli_fetch_array($result))
      echo '<div id="comments"><p>Have you seen the <b>' . $row['adjective'] . ' ' . $row['noun'] . '</b>? <br />';
      echo 'They got up and started to <b>' . $row['verb'] . ' ' . $row['adverb'] . '</b>! </p>';
      echo '<span id="footer">Date: ' . $row['dateAdded'] . '</span></div>';


      mysqli_close($dbc);



      ?>


      index file where calls are made:



      <!DOCTYPE html>
      <html>

      <head>
      <title>Mad libs</title>
      <link rel="stylesheet" href="styles.css" type="text/css" />
      </head>

      <body>

      <?php
      require_once('MadLibs.php');

      $mad_libs = new MadLibs();

      $mad_libs->setNoun($_POST['noun']);
      $mad_libs->setVerb($_POST['verb']);
      $mad_libs->setAdjective($_POST['adjective']);
      $mad_libs->setAdverb($_POST['adverb']);

      // How do I remove these and still have the program function??
      // Get entered info form form
      $noun = $_POST['noun'];
      $verb = $_POST['verb'];
      $adjective = $_POST['adjective'];
      $adverb = $_POST['adverb'];

      if (isset($_POST['submit']))
      if ( (!empty($noun)) && (!empty($verb)) && (!empty($adjective)) && (!empty($adverb)) )
      $mad_libs->insertMadLibs($noun, $verb, $adjective, $adverb, $story);
      else
      echo '<span id="error">Please fill out all fields!</span>';



      ?>

      <div id="wrapper">

      <h1>Mad Libs</h1>

      <hr>

      <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      <label for="noun">Enter a <b>Noun</b>: </label>
      <input type="text" name="noun" id="noun" class="input" value="<?php echo $noun; ?>"/>
      <br />

      <label for="verb">Enter a <b>Verb</b> (Present Tense): </label>
      <input type="text" name="verb" id="verb" class="input" value="<?php echo $verb; ?>"/>
      <br />

      <label for="adjective">Enter an <b>Adjective</b>: </label>
      <input type="text" name="adjective" id="adjective" class="input" value="<?php echo $adjective; ?>"/>
      <br />

      <label for="adverb">Enter an <b>Adverb</b>: </label>
      <input type="text" name="adverb" id="adverb" class="input" value="<?php echo $adverb; ?>"/>
      <br />

      <input name="submit" id="submit" type="submit" value="Submit"/>
      </form>

      </div>

      <?php
      $result = $mad_libs->fetchStory();
      $mad_libs->displayStory($result);
      ?>

      </body>

      </html>






      beginner php object-oriented mysql






      share|improve this question









      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 1 min ago









      200_success

      131k17157422




      131k17157422






      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 hours ago









      jpsweeney94jpsweeney94

      61




      61




      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes












          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217043%2fphp-mad-libs-with-oop-and-sql%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.












          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.











          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217043%2fphp-mad-libs-with-oop-and-sql%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

          Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

          Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar