Jump to content

MYSQL ON MY WEBSITE?


WeExClan

Recommended Posts

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
Share on other sites

Possibly the DB select. Try this (also, please post code in the code tags, as it makes it far easier to read):

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

Link to comment
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
Share on other sites

I assume that there is a "Members" table in the database that you're connecting to? Have you tried running that query manually using phpMySQLAdmin, or any other SQL tool, using the same connection parameters that you're using on this page?

Link to comment
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.