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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-27-2006, 10:57 AM
|
#1
|
Member
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158
Rep:
|
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) {
$string= str_replace("'", "\'", $string);
$string= str_replace("`", "\'", $string);
$string= str_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>
|
|
|
06-27-2006, 11:08 AM
|
#2
|
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379
Rep: 
|
What is your error?
Do you have the mysql code loaded? {note there are two versions mysql and mysqli (improved)}
|
|
|
06-27-2006, 11:21 AM
|
#3
|
Member
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158
Original Poster
Rep:
|
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($result, 0, 0);
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"
|
|
|
06-27-2006, 11:38 AM
|
#4
|
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379
Rep: 
|
What does phpinfo() tell you?
|
|
|
06-27-2006, 12:19 PM
|
#5
|
Member
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158
Original Poster
Rep:
|
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.
|
|
|
06-27-2006, 12:48 PM
|
#6
|
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379
Rep: 
|
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.
|
|
|
06-27-2006, 01:21 PM
|
#7
|
Member
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158
Original Poster
Rep:
|
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.
|
|
|
06-27-2006, 01:36 PM
|
#8
|
Member
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158
Original Poster
Rep:
|
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!
|
|
|
All times are GMT -5. The time now is 12:56 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|