Jump to content

[RESOLVED] mysql_fetch_array(): supplied argument is not a valid MySQL


flash gordon

Recommended Posts

Hi,

This coding runs fine on my server and localhost, but when I throw it up on someone else server running PHP Version 4.4.4 I get errors:

[code]
<calendar year="2006">

<January>
<br/>
<b>Warning</b>
:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
<b>/home/keyclub/public_html/calendar/events.php</b>
on line
<b>31</b>
<br/>
</January>

<February>
<br/>
<b>Warning</b>
:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
<b>/home/keyclub/public_html/calendar/events.php</b>
on line
<b>31</b>
<br/>
</February>
...truncated
[/code]

Here is my php script:

[code=php:0]
<?php

include("calendar_pass.php");


//-------connect to database
mysql_connect("localhost", $username, $password) or die ("Could not connect to database");
mysql_select_db($database) or die ("Could not select database");


// set up year
if (isset($_GET['year'])) $year = $_GET['year'];
else   $year = date("Y");



//    MAKE THE XML DOC
header("Content-Type: application/xml; charset=ISO-8859-1");
echo '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
echo '<calendar year="' . $year . '" >';


for ($i=1; $i<13; $i++) {
$month = $i;

$query = "SELECT * FROM $table WHERE month='" . $month . "' AND year ='" . $year . "'";
$myQuery = mysql_query($query);

echo "<" . date("F", mktime(0, 0, 0, $month, 1, $year)) . ">";  // <January>

while ($row = mysql_fetch_array($myQuery, MYSQL_BOTH ) ) {  // <<<------LINE WITH THE ERROR

echo '<event date="' . $row['day'] . '">';  // <event date="12">
echo '<bands headliner="' . $row['headliner'] . '" band2="' . $row['band2'] . '" band3="' . $row['band3'] . '" />';
echo '<tickets url="' . $row['tickets'] . '" />';
echo '<picture url="' . $row['picture'] . '" />';
echo '<links link1="' . $row['link1'] .  '" link2="' . $row['link2'] .  '" link3="' . $row['link3'] .  '" />';
echo '<description text="' . $row['description'] . '" />';
echo '</event>';


}

echo '</' . date("F", mktime(0, 0, 0, $month, 1, $year)) . ">";  // </January>

}
echo '</calendar>';

mysql_close();
?>
[/code]

Any ideas what is going on here?

Thanks a lot for your time.
Cheers.
:)
Link to comment
Share on other sites

Sorry for posting...It is amazing what google and a translator will give you....

[code=php:0]
for ($i=1; $i<13; $i++) {
$month = $i;

$query = "SELECT * FROM $table WHERE month='" . $month . "' AND year ='" . $year . "'";
$myQuery = mysql_query($query);
echo mysql_error (); // <<-----ECHO OUT REAL ERROR

[/code]

Cheers
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.