I found a basic tutorial on YouTube to create one... I have gotten the code to connect to the localized server by creating a record, but nothing displays in the browser... I can see a record being added when I view the database in PHPmyadmin.
When my code is rendered in the browser the form to add a record (obviously) loads, but nothing no data that should be within the while loop.
I get an error message "
Warning: mysql_result() expects at least 2 parameters, 1 given in [pathname]
Invalid query:"
searched and tried to find an answer. php.net manual is dry and gives me this: mysql_result ( resource $result , int $row [, mixed $field = 0 ] )
I have added another parameter:
$result = mysql_result($query,'*'); and then I get the error:
"Warning: mysql_result() expects parameter 1 to be resource, string given in [pathname]
Invalid query:"
To review what a resource is I find a stackoverflow answer that proves why I decided to try my second attempt.
while($row = mysql_fetch_array($password)) { <-------- $password as resource
$password = $row['password']; <-------- $password as string
}
THEN, someone had a simular example like my code on another forum, and an individual wrote that the logic was awful and to rewrite it......
I am just making a simple CRUD php template to interact with a database... I am not the best programer, does anyone know how to use 2 parameters using mysql_query(1p,2p);?
It is getting a little overwhelming when I try to find an answer to this problem and I see people responding, "use mysqli_query... wow, I just want to grasp mysql, then I could move on to mysqli.
Here is the code I am getting the errors with:
- Code: Select all
<?php
include "./includes/connection.php";
$query = "SELECT * FROM people";
$result = mysql_result($query,'*');
if(!$result) {
die('Invalid query: ' . mysql_error());
}
while($person = mysql_fetch_array($result)) {
echo "<h3>" . $person['Name'] . "</h3>";
echo "<p>" . $person['Description'] . "</p>";
}
?>
<h1>Create a user</h1>
<form action="create.php" method="post">
Name:<input type="text" name="inputName" value="" /><br />
Description:<input type="text" name="inputDesc" value="" /><br />
<input type="submit" name="submit" />


It works! well displaying the information! I cannot thank you enough, I was stressing over this just thinking about it.