Click to See Complete Forum and Search --> : Simple MySQL/PHP Question


chadsten
07-02-2008, 02:37 PM
Ok, I am using a user auth system, and when the user is not authorized to view a page, it will give a fail message. I am using an 'if my_sql_num_rows', so when there are none (user not allowed), how do I hide these messages.

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 6 in /home/hillsand/public_html/tracker/require/edit_lead.php on line 12

Like I said, it is all working, I just need to hide this little guy. Thanks!

chazzy
07-02-2008, 04:22 PM
you'll have to show us what you're doing. if you do mysql num rows before you try to access any of the rows, you should not be getting that error.

chadsten
07-02-2008, 04:36 PM
you'll have to show us what you're doing. if you do mysql num rows before you try to access any of the rows, you should not be getting that error.

Ok, I really need to learn how to communicate. :) LoL. There will be one row that will be counted if


"SELECT sold
FROM properties
WHERE users LIKE '%$current_user%'
AND lead_name= '$lead_name'";


they have permission to access the lead (row). If not, then it tries to select a row that is nonexistent. I just need to hide the warning in my original post if the user does NOT have permissions. It will show the SQL warning, and will continue and show the error I have coded in for a user-bounce. I remember reading somewhere about hiding these types of warnings for security purposes. I hope this helps! Thanks!

chazzy
07-02-2008, 07:55 PM
can you please just post the PHP code you're executing?

chadsten
07-02-2008, 08:59 PM
$project_users = "SELECT sold
FROM properties
WHERE users LIKE '%$current_user%'
AND lead_name= '$lead_name'";

$usr_result = mysql_query($project_users) or die (mysql_error());
$usr_ehco = mysql_result($usr_result, 0);
echo $usr_echo;
//checks to see if the user has permissions to access the CURRENT page being pulled
//require() will be used to pull full/predominatly HTML content in order to save on the echo and passing of HTML strings
if (mysql_num_rows($usr_result) >= 1) {
require ("require/edit_page.php");
}
else {
echo "<div align='center'>Failure!<br />You are <strong>NOT</strong> have permission to access this page.<br />Your IP address has been logged.</div>";
}


All the variables that aren't defined here are defined in the main page. Shouldn't need that one tho, seeing as how it works. Thanks!

chazzy
07-03-2008, 01:05 PM
You should be doing this.


$project_users = "SELECT sold
FROM properties
WHERE users LIKE '%$current_user%'
AND lead_name= '$lead_name'";

$usr_result = mysql_query($project_users) or die (mysql_error());
//checks to see if the user has permissions to access the CURRENT page being pulled
//require() will be used to pull full/predominatly HTML content in order to save on the echo and passing of HTML strings
if (mysql_num_rows($usr_result) >= 1) {
$usr_ehco = mysql_result($usr_result, 0);
echo $usr_echo;
require ("require/edit_page.php");
}
else {
echo "<div align='center'>Failure!<br />You are <strong>NOT</strong> have permission to access this page.<br />Your IP address has been logged.</div>";
}


See the difference? you can't use mysql_result, mysql_fetch_*, etc if the number of rows is off.

chadsten
07-07-2008, 10:31 AM
Ooooooooooohhhh. LoL. You are my hero Chazzy. My working class hero.

rm_webdeveloper
07-16-2008, 02:02 AM
$usr_ehco = mysql_result($usr_result, 0);
echo $usr_echo;

in your code "ehco" it should be "echo"

try to look the $usr_ehco and $usr_echo.

chadsten
07-16-2008, 09:56 AM
Good eye! That was a debug line that is gone now, but way to spot it. :)