Note that there are some explanatory texts on larger screens.

plurals
  1. POusing class method to pull database info
    primarykey
    data
    text
    <p><strong>Overview:</strong> I have a function that is supposed to pull a row of the db based on its id number</p> <p><strong>Problem:</strong> It seems my function is returning, but it isn't returning anything.</p> <p><strong>Details:</strong></p> <p>-I have 2 different files used here: db_class.php and character_pull.php </p> <p>-Also I have a database that contains 1 table (characters) that does contain column "id"</p> <p>-there are echo lines for debugging. I will give what the output is.</p> <p><strong>character_pull.php:</strong></p> <pre><code>&lt;?php include "db_class.php"; echo "made it out here1"; $classobject = new db_class(); echo "made it out here2"; $results = $classobject-&gt;getPlayerStats("1"); print_r($results); echo "made it out here3"; $id = "id: " . $results['id']; $name = "name: " . $results['charname']; $strength = "strength: " . $results['strength']; $defense = "defense: " . $results['defense']; $health = "health: " . $results['health']; $level = "level: " . $results['level']; $type = "type: " . $results['type']; $experience = "experience: " . $results['experience']; echo"&lt;br/&gt;"; echo "made it out here4"; ?&gt; </code></pre> <p><strong>db_class.php:</strong></p> <pre><code>&lt;?php include "database_connect.php"; class db_class{ public function getPlayerStats($id){ echo "&lt;br/&gt;" . "making it in class1"; $query = "SELECT * FROM characters WHERE id = $id"; $result = mysqli_query($query); return $char = mysqli_fetch_array($result); $result -&gt;close(); } } </code></pre> <p>?></p> <p>the output I receive when I run the page is this:</p> <blockquote> <p>made it out here1made it out here2 making it in class1made it out here3 made it out here4</p> </blockquote> <p>I have tried several things to fix this, but am having trouble figuring out what is wrong.</p> <p>I know that this is probably extremely sloppy and primitive, but try not to laugh too hard and maybe you can help me out :P. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload