Here is config.php:
[PHP]<?php //The vars are all ok.
$dbhost = 'localhost';
$dbname = 'forum';
$dbuser = 'toor';
$dbpass = '';
?>[/PHP]
Here is a part of functions.php:
[PHP]<? require "config.php "; //It is in the same directory.
...
function num(){
$start = mysql_connect($ dbhost, $dbuser);
mysql_select_db ($dbname);
$d = mysql_query("SE LECT id FROM atable;");
$c = mysql_num_rows( $d);
mysql_close($st art);
return $c;
}
function id($aa){
$start = mysql_connect($ dbhost, $dbuser);
mysql_select_db ($dbname);
$d = mysql_query("SE LECT id FROM atable;");
$zxc = mysql_fetch_row ($d);
mysql_close($st art);
return $zxc[$aa];
}
...
?>[/PHP]
Part of index.php:
[PHP]<?
...
$cx = num();
for($zp=0;$zp<= $cx;$zp++){
$office = id($zp);
echo "<option>";
echo $office;
echo "</option>";
}
...
?>[/PHP]
There are 13 id in atable.
The problems:
1- When i use the variables from config.php, both functions return null values
2- When i do not use tha vars from config.php, the num() function returns the correct value. But id() only returns the first id from atable.
Can anyone helpme ?????
[PHP]<?php //The vars are all ok.
$dbhost = 'localhost';
$dbname = 'forum';
$dbuser = 'toor';
$dbpass = '';
?>[/PHP]
Here is a part of functions.php:
[PHP]<? require "config.php "; //It is in the same directory.
...
function num(){
$start = mysql_connect($ dbhost, $dbuser);
mysql_select_db ($dbname);
$d = mysql_query("SE LECT id FROM atable;");
$c = mysql_num_rows( $d);
mysql_close($st art);
return $c;
}
function id($aa){
$start = mysql_connect($ dbhost, $dbuser);
mysql_select_db ($dbname);
$d = mysql_query("SE LECT id FROM atable;");
$zxc = mysql_fetch_row ($d);
mysql_close($st art);
return $zxc[$aa];
}
...
?>[/PHP]
Part of index.php:
[PHP]<?
...
$cx = num();
for($zp=0;$zp<= $cx;$zp++){
$office = id($zp);
echo "<option>";
echo $office;
echo "</option>";
}
...
?>[/PHP]
There are 13 id in atable.
The problems:
1- When i use the variables from config.php, both functions return null values
2- When i do not use tha vars from config.php, the num() function returns the correct value. But id() only returns the first id from atable.
Can anyone helpme ?????
Comment