View previous topic :: View next topic |
Author |
Message |
stevem
Joined: 15 Mar 2003 Posts: 368
|
Posted: Mon Feb 23, 2004 11:05 pm Post subject: |
|
|
Do see the edit in the previous post |
|
Back to top |
|
 |
longbow
Joined: 18 Feb 2004 Posts: 12 Location: mass
|
Posted: Tue Feb 24, 2004 12:48 am Post subject: |
|
|
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 |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 368
|
Posted: Tue Feb 24, 2004 2:46 pm Post subject: |
|
|
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 |
|
 |
longbow
Joined: 18 Feb 2004 Posts: 12 Location: mass
|
Posted: Tue Feb 24, 2004 11:48 pm Post subject: |
|
|
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 |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 368
|
Posted: Wed Feb 25, 2004 11:46 am Post subject: |
|
|
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 |
|
 |
longbow
Joined: 18 Feb 2004 Posts: 12 Location: mass
|
Posted: Wed Feb 25, 2004 11:16 pm Post subject: |
|
|
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 |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 368
|
Posted: Wed Feb 25, 2004 11:26 pm Post subject: |
|
|
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 |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 368
|
Posted: Wed Feb 25, 2004 11:54 pm Post subject: |
|
|
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  |
|
Back to top |
|
 |
longbow
Joined: 18 Feb 2004 Posts: 12 Location: mass
|
Posted: Thu Feb 26, 2004 12:13 am Post subject: |
|
|
THANK YOU SOO MUCH MANN
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 |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 368
|
Posted: Thu Feb 26, 2004 12:05 pm Post subject: |
|
|
Great, glad it worked
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 |
|
Back to top |
|
 |
longbow
Joined: 18 Feb 2004 Posts: 12 Location: mass
|
Posted: Thu Feb 26, 2004 12:51 pm Post subject: |
|
|
thanks alot man you helped so much  _________________ the best acceleration you can get on a mac is 9.8m/s. |
|
Back to top |
|
 |
|