Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem in Migrating From MySQL 3.23 To 4.0. Help please !

Status
Not open for further replies.

toean

Technical User
Mar 3, 2004
3
ID
Hi all !

I am moving my database from MySQL server version 3.23.56 to version 4.0.15 (different webhost) and I get problem in executing my queries :

=========
<---------Some html codes--------->
<?
mysql_connect("localhost","myusername","mypassword");
mysql_select_db("parlemen_com");
$qry = mysql_query("SELECT partai FROM partai WHERE partai LIKE '%$caripartai%'"); \\<--This variable is passed from another page !
$jml = mysql_num_rows($qry);
?>
<p align="center"><font face="Verdana" size="2" color="#400000">There are <b><? echo $jml ?></b> items that match your search!</font></p>
<font face="Verdana" size="2">
<? while($row = mysql_fetch_row($qry)) {
echo "<a href='datapartai.php?partai=";
echo $row[0];
echo "'>";
echo "PARTAI ";
echo $row[0];
echo "</a>";
echo "<br>";
}
?>


=========
The above queries worked fine in version 3.23.56 and returned the desired results e.g. (1) the number of items matching with the search query, and (2) the list of the items.

But on the MySQL v. 4.0.25 it returned error message :

========
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/partai/public_html/php/hasilpencarian.php on line 13

There are that macth your search!


Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/partai/public_html/php/hasilpencarian.php on line 19

============
From the MySQL documentation I learned that the current version uses additional API functions : mysql_store_result() and mysql_use_result() in assosiation with the use of mysql_num_rows() and mysql_fetch_rows().

Could somebody help me with the codes please ? My knowledge on the programming code is very limited.

Thank you very much. I would really appreciate your help.
-toean-
 
There's something about your query that MySQL doesn't like.

At the bare minimum, you should change this line:

Code:
$qry = mysql_query("SELECT partai FROM partai WHERE partai LIKE '%$caripartai%'");

To read:

Code:
$qry = mysql_query("SELECT partai FROM partai WHERE partai LIKE '%$caripartai%'") [red] or die(mysql_error());[/red]

Additional steps are to print your query out as the program creates it:

Code:
$query = "SELECT partai FROM partai WHERE partai LIKE '%$caripartai%'";
print $query;
exit();
$qry = mysql_query($query);

Examine the query produced. Does it look right?

Copy the query from your web browser and paste it into your preferred MySQL admin tool. What does MySQL have to say about the query?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks sleipnir214 for your response. Sorry for my delay.

I have executed your code in phpMyAdmin but it did not work, with something like 'syntax error corresponding to server version' message.

Below is what I read from their manual on C API Function Description section :

=================
20.1.3.55 mysql_store_result()

MYSQL_RES *mysql_store_result(MYSQL *mysql)

Description
You must call mysql_store_result() or mysql_use_result() for every query that successfully retrieves data (SELECT, SHOW, DESCRIBE, EXPLAIN).


And this one :

20.1.3.19 mysql_fetch_row()

MYSQL_ROW mysql_fetch_row(MYSQL_RES *result)

Description
Retrieves the next row of a result set. When used after mysql_store_result(), mysql_fetch_row() returns NULL when there are no more rows to retrieve. When used after mysql_use_result(), mysql_fetch_row() returns NULL when there are no more rows to retrieve or if an error occurred.

Etc....

==================

In my humble opinion, my old script was rejected by those rules which unfortunately I am not able to translate them into the correct coding.

Any ideas?

Regards,
-toean-
 
I think my first suggestion, if correctly applied, should give us some information.

You posted a PHP script. I recommended changes to that script.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top