Jump to content

Problem with SQL in PHP


GoodVibe

Recommended Posts

Hows it going guys.

 

I am currently having a problem. I had a program that worked. I migrated the website and now the program is broken.

 

Any time i try to run it, i get this error:

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/thegoo20/public_html/class/wordgame/wordgame.php on line 31

 

Here is the code at that point:

 

function changeword(){
  $result = mysql_query("Select words from CurrentWords");
  $totalwords = array();
  
   while ($row = mysql_fetch_array($result)){
      $totalwords[] = $row["words"];
   }
  $_SESSION['word'] = $totalwords[rand(0, count($totalwords)-1)];
  
  $_SESSION['scrambled'] = str_shuffle($_SESSION['word']);
  
  
}

 

where line 31 is the while statement.

 

Any help would be appreciated.

 

Thanks

Link to comment
Share on other sites

Ok.

 

running that gives me the error:

 

No database selected.

 

If I go to my connection file, this is the code:


<?php
    //Connect to DB
   $con = mysql_connect("localhost","thegoo20_user","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("thegoo20_wordgame", $con);
?>

 

When i run this file by itself, it does not give me any sql errors, so I thought that it was working fine. Maybe I am missing something?

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.