2 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
3 // Copyright (C) 2010 Winch Gate Property Limited
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Affero General Public License as
7 // published by the Free Software Foundation, either version 3 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Affero General Public License for more details.
15 // You should have received a copy of the GNU Affero General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 include('../config.php');
20 // connect to database
21 function connectToDatabase($dbhost, $dbname, $dblogin, $dbpasswd)
23 if (!mysql_connect($dbhost, $dblogin, $dbpasswd))
24 return "Unable to connect to MySQL server (host='$dbhost' login='$dblogin')";
25 if (!mysql_select_db ($dbname))
26 return "Unable to select MySQL database '$dbname'";
30 // default connection to database
31 function defaultConnectToDatabase()
33 global $dbhost, $dbname, $dblogin, $dbpassword;
34 return connectToDatabase($dbhost, $dbname, $dblogin, $dbpassword);
37 function sqlquery($query)
41 $res = mysql_query($query);
42 $sqlQueries[] = $query.(($res)?
"":" ***FAILED***: ".mysql_error());
46 function sqlfetch(&$result)
48 return mysql_fetch_array($result);
51 function sqlnumrows(&$result)
53 return mysql_num_rows($result);
56 function sqlchrows(&$result)
58 return mysql_affected_rows($result);
61 function displayQueries()
64 if (isset($sqlQueries))
66 echo "<br><br><hr><ul>";
67 foreach ($sqlQueries as $query)
68 echo "<li>$query</li>\n";
71 echo "<br><br><p align=right><textarea rows=15 cols=100 readOnly>";
72 foreach ($sqlQueries as $query)
81 echo "<textarea rows=15 cols=100 readOnly>";