Re: Help on Function?
| From: | Cynic | Date: | Wed, 06 Dec 2000 20:48:42 +0000 |
| Subject: | Re: Help on Function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28983@lists.php.net to get a copy of this message | ||
Hi Calvin,
try removing the at-signs and you'll see the problem.
You don't pass the $hostname, $mydatabase etc variables
to the function, nor you assign values to them in the function.
You need to use $GLOBALS['hostname'] etc, or pass them as
arguments.
Besides, why do you pass $insert etc variables to the function,
when you set them to false prior any use?
Another note: you have to return the variables, or do somehing
like
if ($value=='Insert'){
$GLOBALS['insert']=true;
}
At 21:30 6.12. 2000, Wee Chua wrote the following:
--------------------------------------------------------------
>Hi all,
>Sorry for the previous email. I am using the following codes in my main page
>and it works fine but I have to repeatedly put it in every if conditions.
>So, i tried to create a funtion called priv_check($insert,$update,$delete)
>but once I move the same codes into the function, none of it works. Could
>anyone point me out the errors at or how could I fix it?
>
>before I put following codes into function it gave me 1,1,0 of the value
>$insert,$update,$delete but after putting it and i got 0,0,0 of those three
>variables.
>
>function priv_check($insert,$update,$delete) {
> $privilege=@mysql_query("Select Table_priv from
> mysql.tables_priv where host='$hostname'
> && db='$mydatabase' && user=
> '$PHP_AUTH_USER' && table_name=
> '$table'",$db);
>
> $query=@mysql_fetch_array($privilege);
> $value_array = explode(',',
> $query['Table_priv']);
>
> $select=false;
> $insert=false;
> $update=false;
> $delete=false;
>
> while(list(,$value)=each($value_array))
> {
> if ($value=='Insert'){
> $insert=true;
> }
> if ($value=='Update'){
> $update=true;
> }
> if ($value=='Delete'){
> $delete=true;
> }
> }
>
>}
>
>Calvin Chua
>Systems Analyst
>InterClean Equipment, Inc.
>734-975-2967
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz
ICQ: 2808 2505