Page 1 of 1

Differences in college & company

Posted: Mon Feb 02, 2004 12:44 am
by anjanesh
In college my scripts work fine. But in the Company there are some issues esp related to mysql.

Line 24:

Code: Select all

mysql_select_db("rac");
$query=mysql_query('select * from projects where substring(categories,'.$category.',1)="1"');
print('<table border=1 width="100%">');
for($i=0;$i<mysql_num_rows($query);$i++)
 {
 // print in table etc etc 
 }
It works fine in college (Win2k3server,IIS6) but in my Co (Win2kp,IIS5) I get this :

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\anjanesh\OpenProjects.php on line 25

Similarly for this :

Code: Select all

&lt;form action="SignIn.php"&gt;
&lt;td&gt;Username : &lt;/td&gt;
&lt;td&gt;&lt;input maxlength=20 title="Enter the username here" name=username&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password : &lt;/td&gt;
&lt;td&gt;&lt;input type="password" maxlength=20 title="Enter your password here" name=pass&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;input type=submit value="Sign In" name=SignIn&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/form&gt;
The url sent is : http://localhost/anjanesh/SignIn.php?us ... In=Sign+In

In college its working. The Script SignIn.php contains :

Code: Select all

if(!isset($username) || !isset($pass)) die("Unable to authorize you");
But in the Co, I get Unable to authorize you even when mysql etc is working fine.

The scripts seem to be fine but I don't understand why it does not work in the Co esp when using mysql db scripts.

Thanks

Posted: Mon Feb 02, 2004 1:56 am
by timvw
what do

mysql_connect(......) or die(mysql_error());
mysql_select_db(....) or die(mysql_error());
mysql_query($query) or die(mysql_error());


tell you?

Posted: Mon Feb 02, 2004 7:51 am
by Pointybeard
Simple debugging. try echoing your queries to make sure they are valid. You got register_globals on? How about putting in lots of echo statements to see what your variables are at certain points. Also a better option for your login stuff would be to POST your form rather than GET. Makes it more secure,.

Code: Select all

<form action="SignIn.php" method=POST>

Code: Select all

if(!isset($_POST[username]) || !isset($_POST[pass])) die("Unable to authorize you");
Hope that helps.