web/getdb.inc
author viric@llimona
Thu, 18 May 2006 22:59:47 +0200
changeset 0 6371497b4e53
permissions -rw-r--r--
Init from svn. The wxpython is the final one.
<?php
$mysql_server = "localhost";
$mysql_user = "lingvigilouser";
$mysql_password = "carrinclo";
$mysql_db = "lingvigilo";
$frazotablo = "frazoj_ru_ca";

function konekti()
{
	global $mysql_server, $mysql_user, $mysql_password, $mysql_db;
	$connexio = mysql_connect($mysql_server, $mysql_user, $mysql_password);
	mysql_select_db($mysql_db, $connexio);
	return $connexio;
}


function strtosql($cadena)
{
	return ereg_replace("\'", "\'", $cadena);
}


function preni_frazojn($konekto,$fraztipo=0)
{
	global $frazotablo;
	$resultat = mysql_query(
		"SELECT id,vorto,frazo,korekta,klarigo,korektisto FROM " .
		$frazotablo . " WHERE korekta=" . $fraztipo . ";",
		$konekto);

	echo mysql_error();

	while ($fila = mysql_fetch_row($resultat))
	{
		$frazoj[$fila[0]] = array(
				"vorto" => $fila[1],
				"frazo" => $fila[2],
				"korekta" => $fila[3],
				"klarigo" => $fila[4],
				"korektisto" => $fila[5]);
	}

	if (!isset($frazoj))
		$frazoj=0;

	return $frazoj;
}

function teksto_korekto($korekteco)
{
	switch($korekteco)
	{
	case 0: return "Ne korektita"; break;
	case 1: return "Ĝusta"; break;
	case 2: return "Malĝusta"; break;
	case 3: return "Nekutima"; break;
	}
}
?>