Jump to content

MYSQL ON MY WEBSITE?


WeExClan

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

Archived

This topic is now archived and is closed to further replies.

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