Jump to content

Recommended Posts

So you just want a PHP page that gets a list from a table in MySQL and displays it for you? If so, you've posted in the wrong place, as that would be PHP and MySQL, not just HTML. Start with a simple PHP/MySQL tutorial like this one:

http://www.w3schools.com/php/php_mysql_select.asp

Link to comment
https://forums.phpfreaks.com/topic/202747-mysql-on-my-website/#findComment-1062635
Share on other sites

Here is the error in the browser:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /~/www/****.tk/members/index.php on line 18

 

**** = I'm hiding whats really there...

Here is the script:

<?php

$con = mysql_connect("***","***","****");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("my_db", $con);

 

$result = mysql_query("SELECT * FROM Members");

 

echo "<table border='1'>

<tr>

<th>PSN Navn</th>

<th>Navn</th>

</tr>";

 

while($row = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $row['login'] . "</td>";

  echo "<td>" . $row['FirstName'] . "</td>";

  echo "</tr>";

  }

echo "</table>";

 

mysql_close($con);

?>

Link to comment
https://forums.phpfreaks.com/topic/202747-mysql-on-my-website/#findComment-1062664
Share on other sites

Ok, when i added your thingy it said some could not connect thing but i fixed it and now its the same as it was...

 

This is the code now:

<?php
$con = mysql_connect("****","****","****");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$db_con = mysql_select_db("****", $con);
if (!$db_con)
  {
  die('Could not connect to "****": ' . mysql_error());
  }

$result = mysql_query("SELECT * FROM Members");

echo "<table border='1'>
<tr>
<th>PSN Navn</th>
<th>Navn</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['login'] . "</td>";
  echo "<td>" . $row['FirstName'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

 

The error is still:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /~/www/****.tk/members/index.php on line 22

Link to comment
https://forums.phpfreaks.com/topic/202747-mysql-on-my-website/#findComment-1062683
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.