Jump to content

matthew9090

Members
  • Posts

    135
  • Joined

  • Last visited

    Never

Everything posted by matthew9090

  1. i used this example of the internet first: <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM Persons"); echo "<table border='1'> <tr> <th>Firstname</th> <th>Lastname</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Then i used this one: <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Get all the data from the "example" table $result = mysql_query("SELECT * FROM example") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Age</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['name']; echo "</td><td>"; echo $row['age']; echo "</td></tr>"; } echo "</table>"; ?>
  2. problem solved!!!! i used a different script of the internet
  3. i added the ; at the end of the line but it still says the same thing
  4. i got this code from w3schools.com and just changed the values. can someone please show me the code with the correct syntax.
  5. i have added the line now it says: Parse error: syntax error, unexpected T_WHILE, expecting ',' or ';' in (location) on line 15
  6. Help i don't under stand why this doen't work it says: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in (file location) on line 14 This is the script: <?php $con = mysql_connect("localhost","usr","Pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db_name", $con); $result = mysql_query("SELECT * FROM tablename"); while($row = mysql_fetch_array($result)) { echo $row['row'] . " " . $row['email']; echo "<br />"; } mysql_close($con); ?> while($row = mysql_fetch_array($result)) is line 14
×
×
  • 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.