...

View Full Version : mysql_result error: invalid resource



jaywhy13
12-24-2006, 09:44 PM
What am I doing wrong?


<?php
//header ("Context-Type: text/xml");
$usr = $_GET["usr"];


$psw = $_GET["psw"];

echo "Username is: $usr, and psw is: $psw";

$conn = mysql_connect ("localhost","jay","") or die ("No connection available");
$db = mysql_select_db ("rlaPool") or die ("Could not find database");

$query = "SELECT * FROM usrs WHERE usrs.usr=$usr";

$result = mysql_result ($result,$conn) or die ("<b>That didn't work!!!!</b>") ;

?>

I get error
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/jail/labtec/login.php on line 14

If I try

$result = mysql_result ($result) or die ("<b>That didn't work!!!!</b>") ;

I get wrong param count


Someone plz just quickly call me stupid and tell me what I did wrong... coz I can't belive I'm stuck at this point.

bhav
12-24-2006, 09:51 PM
<?
$conn = mysql_connect ("localhost","jay","") or die ("No connection available");/* remember that it will be for example if your hosting account name was domain the sql username would be domain_jay not just jay*/


$db = mysql_select_db ("rlaPool") or die ("Could not find database"); /* same goes here so it would be domain_rlaPool */
?>

jaywhy13
12-24-2006, 10:08 PM
But I have die statements for all of them, if I comment out the mysql_query line then it gives NO error. And I don't recall ever using the doman_ thing

Crimsonjade
12-24-2006, 10:15 PM
I am not sure I agree with bhav either. I have used hosting where it did not force me to use domain_username.

jaywhy13, i think the solution to your problem is:


$query = "SELECT * FROM usrs WHERE usrs.usr=$usr"; // not sending a query

$result = mysql_query($query); // now my query is sent


edit:
Also, why are you sticking $conn in the mysql_result function?

See this: http://us2.php.net/mysql_result

jaywhy13
12-24-2006, 10:34 PM
I am not sure I agree with bhav either. I have used hosting where it did not force me to use domain_username.

jaywhy13, i think the solution to your problem is:


$query = "SELECT * FROM usrs WHERE usrs.usr=$usr"; // not sending a query

$result = mysql_query($query); // now my query is sent


edit:
Also, why are you sticking $conn in the mysql_result function?

See this: http://us2.php.net/mysql_result


$result = mysql_result ($result,$conn) or die ("<b>That didn't work!!!!</b>") ;

I'm using php 5 and when I try just using result alone if gives me a wrong param count error....


Edit:
I just finished exams @ school, I can tell I am stressed. I really should have been using mysql_query instead of result... That fixed it.

Thanks man... it's working now

Crimsonjade
12-24-2006, 11:03 PM
$result = mysql_result ($result,$conn) or die ("<b>That didn't work!!!!</b>") ;

I'm using php 5 and when I try just using result alone if gives me a wrong param count error....

I think the second parameter is
The row number from the result that's being retrieved. Row numbers start at 0.

Glad it worked.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum