boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

php / mysql problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    boardom Forum Index -> PHP help
View previous topic :: View next topic  
Author Message
stevem



Joined: 15 Mar 2003
Posts: 368

PostPosted: Mon Feb 23, 2004 11:05 pm    Post subject: Reply with quote

Do see the edit in the previous post
Back to top
View user's profile Send private message
longbow



Joined: 18 Feb 2004
Posts: 12
Location: mass

PostPosted: Tue Feb 24, 2004 12:48 am    Post subject: Reply with quote

i still get the error that states mysql_num_rows(): supplied argument is not a valid im running php v4.2, maybe thats not a function in 4.2?
_________________
the best acceleration you can get on a mac is 9.8m/s.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
stevem



Joined: 15 Mar 2003
Posts: 368

PostPosted: Tue Feb 24, 2004 2:46 pm    Post subject: Reply with quote

It is has been a function as far back as version 3 at least. The error message means that the Select stament is not correct. This is why I need more information about your table. If you are having trouble with phpMyAdmin surely WinMySqladmin (which I haven't tried) will allow you to export the table?
Back to top
View user's profile Send private message
longbow



Joined: 18 Feb 2004
Posts: 12
Location: mass

PostPosted: Tue Feb 24, 2004 11:48 pm    Post subject: Reply with quote

Code:
Database test - Table list running on localhost
# phpMyAdmin SQL Dump
# version 2.5.4
# http://www.phpmyadmin.net
#
# Host: localhost
# Generation Time: Feb 24, 2004 at 05:53 PM
# Server version: 4.0.4
# PHP Version: 4.2.3
#
# Database : `test`
#

# --------------------------------------------------------

#
# Table structure for table `list`
#

DROP TABLE IF EXISTS `list`;
CREATE TABLE `list` (
  `id` int(11) NOT NULL auto_increment,
  `list` blob,
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

#
# Dumping data for table `list`
#

INSERT INTO `list` (`id`, `list`) VALUES (1, 0x6c6f6e67626f77);


there you go i got myphpadmin to work
thats the export for the table
_________________
the best acceleration you can get on a mac is 9.8m/s.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
stevem



Joined: 15 Mar 2003
Posts: 368

PostPosted: Wed Feb 25, 2004 11:46 am    Post subject: Reply with quote

I have taken your code and created an identical table in a database which allows me to test the code.

Then I used this:
Code:
$sql = "SELECT * FROM list WHERE list = 'longbow'";
$result = mysql_query($sql);
if (mysql_num_rows($result)>0) {
   echo "It works!";
} else {
   echo "No. Try again";
}

This gives me "It works!" so the code is now correct.

However, I would recommend that you
1. change the list type from blob to text. This allows you to easily edit the value, and puts longbow rather than the harder to read ASCII equivalent of 0x6c6f6e67626f77

2. change the table or field name so not both are called list. This will be less confusing in the code.

[It was my turn to have too many =s. I had list == 'longbow' in a previous post instead of the correct list = 'longbow'. PHP and mySQL do things differently ]
Back to top
View user's profile Send private message
longbow



Joined: 18 Feb 2004
Posts: 12
Location: mass

PostPosted: Wed Feb 25, 2004 11:16 pm    Post subject: Reply with quote

Code:
<?PHP
$conn = mysql_connect("localhost","user","pass");
mysql_select_db("test",$conn);
$log = "SELECT  * FROM  `list` WHERE 'user' = '$_POST[user]'";
$result = mysql_query($log);
if ((mysql_num_rows($result)) > '0')
{
   $dirname = ".";
   $dh = opendir($dirname) or die("couldn't open directory");

   while (!(($file = readdir($dh)) == 0))
   {
         if (is_dir("$dirname/$file"))
      {
              print "<a href= (D) > </a>";
          }
       print"<a href= $file>$file</a><br>";
   }
      closedir($dh);
   }
{
   print"<a href= \"register\">Please register here to veiw the files</a>";
}
?>


this is what i have so far and i am still geting the same results as when i started, not any errors just that it wont "log in"
_________________
the best acceleration you can get on a mac is 9.8m/s.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
stevem



Joined: 15 Mar 2003
Posts: 368

PostPosted: Wed Feb 25, 2004 11:26 pm    Post subject: Reply with quote

Assuming you have now labelled the field as user, this is a name so should not have quotes round it:
Code:
$log = "SELECT  * FROM  `list` WHERE 'user' = '$_POST[user]'";

should be
Code:
$log = "SELECT  * FROM  `list` WHERE user = '$_POST[user]'";

Also you haven't got an else near the end of the code, so the second print will always happen even if you get the list.
You don't need quite so many brackets in
Code:
if ((mysql_num_rows($result)) > '0')

Code:
if (mysql_num_rows($result) > '0')

will do, but it isn't important.
Back to top
View user's profile Send private message
stevem



Joined: 15 Mar 2003
Posts: 368

PostPosted: Wed Feb 25, 2004 11:54 pm    Post subject: Reply with quote

I have also now tried out the rest of your code and it works except that you have made a change which you need to put back.
Code:
   while (!(($file = readdir($dh)) == 0))

should be
Code:
   while (!(($file = readdir($dh)) == false))

With that changed it seems to work here Smile
Back to top
View user's profile Send private message
longbow



Joined: 18 Feb 2004
Posts: 12
Location: mass

PostPosted: Thu Feb 26, 2004 12:13 am    Post subject: Reply with quote

THANK YOU SOO MUCH MANN Mr. Green
i bow down before you and all your PHP godliness LOL
what could i do for ya?
_________________
the best acceleration you can get on a mac is 9.8m/s.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
stevem



Joined: 15 Mar 2003
Posts: 368

PostPosted: Thu Feb 26, 2004 12:05 pm    Post subject: Reply with quote

Great, glad it worked Very Happy

One final thing. You want a (D) when listing a directory which won't happen at the moment as you need to change the line
Code:
print "<a href= (D) > </a>";
to
Code:
print "(D) ";
Back to top
View user's profile Send private message
longbow



Joined: 18 Feb 2004
Posts: 12
Location: mass

PostPosted: Thu Feb 26, 2004 12:51 pm    Post subject: Reply with quote

thanks alot man you helped so much Very Happy
_________________
the best acceleration you can get on a mac is 9.8m/s.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> PHP help All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group