LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-27-2006, 10:57 AM   #1
windisch
Member
 
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158

Rep: Reputation: 30
Upgrade From FC3 to FC5: Issues with PHP/MYSQL


After my upgrade to FC3 I noticed that one of my pages is not working. Its a page that reads a file and searches my MySQL database. The search does not appear to work anymore. Is there something that has changed in MySQL 5.0.22 or PHP Version 5.1.4?

I took out the login, password, and database from this post
PHP Code:
<html>
<head>
<META HTTP-EQUIV="refresh" CONTENT="15;http://windisch.no-ip.org/shoutcast/main.php">
<LINK REL=StyleSheet HREF="shoutcast.css" TYPE="text/css" MEDIA=all>
</head>
<body>

<title>Multiple Ajax Star Rating Bars</title>
<script type="text/javascript" src="js.js"></script>
        <link rel="stylesheet" type="text/css" href="stars.css" />



<?php
include('functions.php');
function 
remover($string$sep1$sep2)
{
#       $string = substr($string, 0, strpos($string,$sep2));     //Finds end position of filename
       
$string substr(strstr($string$sep1), 18);            //Finds beginning of filename
return $string;
}
function 
mysql_addslashes($string) {
   
$stringstr_replace("'""\'"$string);
   
$stringstr_replace("`""\'"$string);
   
$stringstr_replace("/""\/"$string);
return 
$string;
}

$filename "MythMusic.alw";
$handle fopen($filename"r");
if ( 
$handle )
{
#$contents = fread($handle, filesize($filename));
#fclose($handle);
#echo "<P2>$contents</P2>";
$lines file($filename);  //Reads file and puts each line into an array
$count count($lines);    //Puts number of entries in the array into a variable
echo "<P2>There Are $count Songs In The Request Queue:</P2> <br><br>";
$x=0;
?>
<table width="600" height="75" cellpadding="5" border="1" align="center">
<tr>
<?php
while ($x $count) {
$string $lines[$x];
$str1 "/video3/MythMusic/";
$str2 ".mp3";

$string remover($string$str1$str2);
echo 
$string;
$username="";
$password="";
$database="";
mysql_connect('localhost',$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM `musicmetadata` WHERE `filename` = '$string'" or die(" Error: ".mysql_error());
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while (
$i $num) {
global 
$artist;
$artist=mysql_result($result,$i,"artist");
$album=mysql_result($result,$i,"album");
$title=mysql_result($result,$i,"title");
$genre=mysql_result($result,$i,"genre");
$year=mysql_result($result,$i,"year");
$intid=mysql_result($result,$i,"intid");


#$filename=mysql_result($result,$i,"filename");
?><td align="left"><?php echo "<H4><b>Artist: <P2>$artist</P2><br> Title: <P2>$title</P2><br>Album: <P2>$album</P2></b><br> Year: <P2>$year</P2>";


$i++;

?><td align="center"><?php rating_bar($intid);?></td> <?php


}

$x=$x+1;
?>
</td>
</tr>
<?php
}
}
else
{
die (
"<H1>No Request Songs In Queue</H1>");
}
?>
</tr>
</table>
<?php ?>
</body>
</html>
 
Old 06-27-2006, 11:08 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
What is your error?
Do you have the mysql code loaded? {note there are two versions mysql and mysqli (improved)}
 
Old 06-27-2006, 11:21 AM   #3
windisch
Member
 
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158

Original Poster
Rep: Reputation: 30
This is the only error I see in error_log:

Code:
[Tue Jun 27 12:16:40 2006] [error] [client 68.73.129.222] PHP Warning:  mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/html/shoutcast/functions.php on line 44
Which is a different file that the script calls:

PHP Code:
$voted mysql_result($result00); 
What's odd is that all of my other pages that do similar searches, and call functions.php work, only this one seems not to.

Where do I check to see which version I am running? PHPMyAdmin says that it is "MySQL 5.0.22"
 
Old 06-27-2006, 11:38 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
What does phpinfo() tell you?
 
Old 06-27-2006, 12:19 PM   #5
windisch
Member
 
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158

Original Poster
Rep: Reputation: 30
Hopefully this is useful:

Code:
System 	Linux Smaug.Lair 2.6.16-1.2133_FC5 #1 Tue Jun 6 00:52:14 EDT 2006 i686
Build Date 	May 8 2006 08:43:39
Configure Command 	'./configure' '--build=i386-redhat-linux' '--host=i386-redhat-linux' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/etc/httpd/conf/magic' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter'
Server API 	Apache 2.0 Handler
Virtual Directory Support 	disabled
Configuration File (php.ini) Path 	/etc/php.ini
Scan this dir for additional .ini files 	/etc/php.d
additional .ini files parsed 	/etc/php.d/ldap.ini, /etc/php.d/mbstring.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini
Here is what the MySQL section says:

Code:
mysql
MySQL Support	enabled
Active Persistent Links 	0
Active Links 	1
Client API version 	5.0.22
MYSQL_MODULE_TYPE 	external
MYSQL_SOCKET 	/var/lib/mysql/mysql.sock
MYSQL_INCLUDE 	-I/usr/include/mysql
MYSQL_LIBS 	-L/usr/lib/mysql -lmysqlclient

Directive	Local Value	Master Value
mysql.allow_persistent	On	On
mysql.connect_timeout	60	60
mysql.default_host	no value	no value
mysql.default_password	no value	no value
mysql.default_port	no value	no value
mysql.default_socket	no value	no value
mysql.default_user	no value	no value
mysql.max_links	Unlimited	Unlimited
mysql.max_persistent	Unlimited	Unlimited
mysql.trace_mode	Off	Off

mysqli
MysqlI Support	enabled
Client API library version 	5.0.22
Client API header version 	5.0.18
MYSQLI_SOCKET 	/var/lib/mysql/mysql.sock

Directive	Local Value	Master Value
mysqli.default_host	no value	no value
mysqli.default_port	3306	3306
mysqli.default_pw	no value	no value
mysqli.default_socket	no value	no value
mysqli.default_user	no value	no value
mysqli.max_links	Unlimited	Unlimited
mysqli.reconnect	Off	Off

Last edited by windisch; 06-27-2006 at 12:21 PM.
 
Old 06-27-2006, 12:48 PM   #6
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Well the phpinfo looks okay since both are there.

What does functions.php do (esp line 44)
If you echo out the query prior to that line it might give you an idea as to what the problem is.
 
Old 06-27-2006, 01:21 PM   #7
windisch
Member
 
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158

Original Poster
Rep: Reputation: 30
functions.php is part of a ajax star rating system. It works fine on my other pages, but not this one. I will try removing the rating system from the page to rule it out as the problem.
 
Old 06-27-2006, 01:36 PM   #8
windisch
Member
 
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158

Original Poster
Rep: Reputation: 30
Nevermind, I'm an idiot. I didn't realize that the string I was sending to MySQL now seemed to have a space at the end of the string. After trimming it, it works fine. Sorry about the trouble, and thanks again for your help graemef!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing WordPress on FC5 - Mysql / PHP problem ArthurDent Fedora 1 06-25-2006 04:58 PM
Upgrade to MySQL-5.0.18 breaks PHP mysql functions MarkVickers Slackware 5 05-03-2006 12:10 AM
php-mysql dependancy problem after nitemare mysql upgrade. RHEL4 andrewc Red Hat 1 01-03-2006 04:16 PM
FC3 Upgrade Issues Hook99 Linux - Newbie 5 04-29-2005 12:09 PM
Upgrade mysql and php acrors Red Hat 1 08-31-2004 10:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration