Jump to content

need help moving scripts from local to remote


Vizonz

Recommended Posts

Fixed the include problem

now this is a problem

 

Also ken helped me with some scripts and when i try to run them on the server now i get

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in  on line 25
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /

 

these work fine locally but not on the server

Link to comment
Share on other sites

$query = "SELECT DISTINCT
  requestlist.songID, songlist.ID, requestlist.ID, songlist.artist, songlist.title, songlist.count_requested, songlist.composer, requestlist.status
FROM
  radio.requestlist
  INNER JOIN radio.songlist ON requestlist.songID = songlist.ID
WHERE
  requestlist.status = 'played'
GROUP BY
  requestlist.status, songlist.title, songlist.artist
ORDER BY
  songlist.count_requested DESC, songlist.artist DESC LIMIT 30;
";
$result = mysql_query ($query)
or die("Query error: ". mysql_error());
$num=mysql_num_rows($result);
echo "<ol>\n";
while ($row = mysql_fetch_assoc($result)) {
   echo "<li> {$row['artist']}  - <a href='{$row['songID']}'>{$row['title']}</a>        ({$row['count_requested']} ) </li>\n";
}
echo "</ol>\n";
?><br />

 

and i am getting

 

Query error: SELECT command denied to user

 

i am still learning but i am taking a guess  that i dont have privledges set up on that database for that user.

 

what do i run through phpmyadmin to grant that

Link to comment
Share on other sites

Those errors simply mean your query failed and you have done nothing to catch the error. Take  look at mysql_error to see what the actual error is then try and fix it.

Kinda lost me  what exactly i do ? i am learning so when you say that it kinda means nothing to me LOL sorry to be blunt but i am clueless about this
Link to comment
Share on other sites

Actually, your calling....

 

or die("Query error: ". mysql_error());

 

which should show you the data you need. I'm not sure if the code you have posted is actually the code causing the problem now.

Link to comment
Share on other sites

Actually, your calling....

 

or die("Query error: ". mysql_error());

 

which should show you the data you need. I'm not sure if the code you have posted is actually the code causing the problem now.

 

okay lets start from here

 

include("dbinfo.inc.php");
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT DISTINCT
  requestlist.songID, songlist.ID, requestlist.ID, songlist.artist, songlist.title, songlist.count_requested, songlist.composer, requestlist.status
FROM
  radio.requestlist
  INNER JOIN radio.songlist ON requestlist.songID = songlist.ID
WHERE
  requestlist.status = 'played'
GROUP BY
  requestlist.status, songlist.title, songlist.artist
ORDER BY
  songlist.count_requested DESC, songlist.artist DESC LIMIT 30;
";
$result=mysql_query($query);
$num=mysql_num_rows($result);
echo "<ol>\n";
while ($row = mysql_fetch_assoc($result)) {
   echo "<li> {$row['artist']}  - <a href='{$row['songID']}'>{$row['title']}</a>        ({$row['count_requested']} ) </li>\n";
}
echo "</ol>\n";
?><br />

 

thats the code in the page.

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource  on line 24


      Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource  on line 26

 

line 24

$num=mysql_num_rows($result);

 

Line 26

while ($row = mysql_fetch_assoc($result)) {

 

thats where i am rright now

 

 

Link to comment
Share on other sites

You need to check your queries succeed before using there results. At minimum....

 

if ($result = mysql_query($query)) {
  if (mysql_num_rows($result)) {
    echo "<ol>\n";
    while ($row = mysql_fetch_assoc($result)) {
      echo "<li> {$row['artist']}  - <a href='{$row['songID']}'>{$row['title']}</a>        ({$row['count_requested']} ) </li>\n";
    }
    echo "</ol>\n";
  } else {
    // no results found, handle error.
} else {
  // query failed, handle error.
  trigger_error(mysql_error());
}
?>

 

always.

Link to comment
Share on other sites

<?php
include("dbinfo.inc.php");
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT DISTINCT
  requestlist.songID, songlist.ID, requestlist.ID, songlist.artist, songlist.title, songlist.count_requested, songlist.composer, requestlist.status
FROM
  radio.requestlist
  INNER JOIN radio.songlist ON requestlist.songID = songlist.ID
WHERE
  requestlist.status = 'played'
GROUP BY
  requestlist.status, songlist.title, songlist.artist
ORDER BY
  songlist.count_requested DESC, songlist.artist DESC LIMIT 30;
";
$result=mysql_query($query);
$num=mysql_num_rows($result);
if ($result = mysql_query($query)) {
  if (mysql_num_rows($result)) {
    echo "<ol>\n";
    while ($row = mysql_fetch_assoc($result)) {
      echo "<li> {$row['artist']}  - <a href='{$row['songID']}'>{$row['title']}</a>        ({$row['count_requested']} ) </li>\n";
    }
    echo "</ol>\n";
  } else {
    // no results found, handle error.
} else {
  // query failed, handle error.
  trigger_error(mysql_error());
}
?>

 

and its a parse error

Parse error: syntax error, unexpected T_ELSE in   on line 34

 

i took out some of the html above it  so yeah

 

    // no results found, handle error.
} else {

line 34 is the else

Link to comment
Share on other sites

Sorry, there is a missing }

 

if ($result = mysql_query($query)) {
  if (mysql_num_rows($result)) {
    echo "<ol>\n";
    while ($row = mysql_fetch_assoc($result)) {
      echo "<li> {$row['artist']}  - <a href='{$row['songID']}'>{$row['title']}</a>        ({$row['count_requested']} ) </li>\n";
    }
    echo "</ol>\n";
  } else {
    // no results found, handle error.
  }
} else {
  // query failed, handle error.
  trigger_error(mysql_error());
}
?>

 

Also, you can remove those extra calls to mysql_query() and mysql_num_rows() that you have.

Link to comment
Share on other sites

yeah i had to contact them for them to open a ticket to  srt permissions on the database LOL  dedicated servers so much better . but thanks i will let you know  if it works after that :)

 

by the way love your blog  nice design

Link to comment
Share on other sites

sorry wasnt paying attencion its where it was last nothing changed  still same thing same error

 

From the server

Regarding your issue with database connection, has returned from our investigation. It has been determined that database connection is working properly. We have tested and we were able to access database and run sql query for it (please see connection logs below). Please check code in top30.php. We have now closed the ticket with regards to this issue. If you do require any further assistance, please do not hesitate to contact us and we will be glad continue working with you.

Link to comment
Share on other sites

<?php
include("dbinfo.inc.php");
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT DISTINCT
  requestlist.songID, songlist.ID, requestlist.ID, songlist.artist, songlist.title, songlist.count_requested, songlist.composer, requestlist.status
FROM
  radio.requestlist
  INNER JOIN radio.songlist ON requestlist.songID = songlist.ID
WHERE
  requestlist.status = 'played'
GROUP BY
  requestlist.status, songlist.title, songlist.artist
ORDER BY
  songlist.count_requested DESC, songlist.artist DESC LIMIT 30;
";

$result=mysql_query($query);
if ($result = mysql_query($query)) {
  if (mysql_num_rows($result)) {
    echo "<ol>\n";
    while ($row = mysql_fetch_assoc($result)) {
      echo "<li> {$row['artist']}  - <a href='{$row['songID']}'>{$row['title']}</a>        ({$row['count_requested']} ) </li>\n";
    }
    echo "</ol>\n";
  } else {
    // no results found, handle error.
  }
} else {
  // query failed, handle error.
  trigger_error(mysql_error());
}
?>

theres the code  though

Link to comment
Share on other sites

i am an idiot :P i know why LOL its a new database name  i forgot to change it in the query :P\

 

where it had radio. in the query was the localhost database i just removed that and it now works.  thanks for the help with the actual php though the rest was my stupidity

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.