PHP code part, the problem is here, not normal to make judgments.
Open in '; Echo 'Stop in ';} else{ Echo 'Stop in '; Echo 'Open in '; }? >
Function part:
Website basic information, get content according to field function sysname ($field) {$sql = "select * from System"; $query =mysql_query ($sql); $rs =mysql_fetch_ Array ($query); echo $rs ["$field"];}
The Webstate field in the database uses the Char type field function to output normally, just can't judge.
Help.
Reply to discussion (solution)
function sysname ($field) { $sql = "SELECT * from System"; $query =mysql_query ($sql); $rs =mysql_fetch_array ($query); Retrun $rs [$field]; Here is the return}
function sysname ($field) { $sql = "SELECT * from System"; $query =mysql_query ($sql); $rs =mysql_fetch_array ($query); Retrun $rs [$field]; Here is the return}
If I want to call directly on the display, how to write it?
function sysname ($field) { $sql = "SELECT * from System"; $query =mysql_query ($sql); $rs =mysql_fetch_array ($query); Retrun $rs [$field]; Here is the return}
If you write like this, you will report the error directly.
Parse error:syntax error, unexpected t_variable in points to the last line, i.e. Retrun $rs [$field];
Sorry, wrong hand!
Retrun
should be for
Return
Sorry, wrong hand!
Retrun
should be for
Return
What if I wanted to be able to display directly in the function and not echo when I was tuning it?
I have written before, you can do it without echo, but used to judge it. I don't understand. Please mention one or two, thank you.
1. Return $rs in function [$field];
2. var_dump (sysname ("webstate") output is available when judging.
In the function echo just output or print, return is the function return value, can judge.
Return
1, you first learn to debug, through the breakpoint debugging can find the problem out there, only know the problem again that, can be modified.
2, note: You see sometimes can not see the problem.
3. Solution:
function sysname ($field) {
$sql = "SELECT * from System";
$query =mysql_query ($sql);
$rs =mysql_fetch_array ($query);
return $rs [$field];//without quotation marks
}
On the PHP page: $aa = sysname ("webstate"); Var_dump ($AA); see $aa can output Y No, if you can, in the judgment statement if ($aa = = "Y") {echo "AA";} Else{echo "BB";} See what the output, step by step debugging you can solve.
1. Return $rs in function [$field];
2. var_dump (sysname ("webstate") output is available when judging.
Hello, first of all thank you for your help, but no. Print it Out is Ynull
What is your return value now?
There may be more than one record in the system table of the database, and the field you are querying is not in the first record.
Why don't you take a look at the system table?