Hallo
Die Datenbank ist MySQL!!
Ich möchte für 2 verschiedene Anfragen (verschiedene Felder) in eine Anfrage vereinen.
Das Ergebniss der "Erfüllung" und der nicht "Erfüllung" sollte bei beiden Anfragen zur selben "else" führen.
Der als Komentar (/*-*/) ausgesetzte Code ist der zweite den ich einbauen müßte!
Beide einzeln funtionieren!!
Aber es müßten beide mit einem "else" funktionieren!!
Hier der Code:
(fängt nacht der Klassen Declaration an)
<?php
class mysql_db {
var $link = false;
var $resid = false;
var $doerror = false;
var $host = "localhost";
var $user = "xxxxx";
var $passwd = "xxxxx";
var $tables = "votum_alex";
function set_doerror($boolvalue)
{
$this->doerror = $boolvalue;
}
function connect()
// Verbindet zur Datenbank
{
$temp = @mysql_connect
($this->host, $this->user, $this->passwd);
if (!$temp)
{
$this->echoerror();
return false;
}
$this->link = $temp;
$temp = @mysql_select_db($this->tables, $temp);
if (!$temp)
{
$this->echoerror();
return false;
}
return $this->link;
}
function query($sql)
// Sendet eine Anfrage an die Datenbank
{
if (!$this->link)
{
if ($this->doerror)
{
echo ("
Nicht verbunden.
");
return false;
}
}
if ($this->resid) @mysql_free_result($this->resid);
$result = mysql_query($sql);
if (!$result) $this->echoerror();
$this->resid = $result;
return $result;
#, $this->link)
}
function echoerror()
// erzeugt eine Fehlerausschrift
// wenn $doerror=TRUE
{
if (!$this->doerror) return;
if (!mysql_errno()) return;
echo ("<font color=\"red\">
" . mysql_errno());
echo (": ". mysql_error() ." </font>
");
}
function data()
// liefert einen Datensatz
{
if (!$this->link)
{
if ($this->doerror)
echo ("
Nicht verbunden!
");
return false;
}
if (!$this->resid)
{
if ($this->doerror)
echo ("
Keine Abfrage!
");
return false;
}
$result = mysql_fetch_array($this->resid, MYSQL_BOTH);
$this->echoerror();
return $result;
}
function echoquery($sql)
//Fragt die Datenbank ab und stellt die Abfrage dar
{
$this->query($sql);
echo("<table border cellpadding=\"3\"><tr>");
$index = 0;
echo("<th>record</th>");
while ($field = mysql_fetch_field($this->resid))
echo("<th>$field->name</th>");
echo ("</tr>\n");
$rec=0;
while ($row = $this->data())
{
$rec++;
echo("<tr><td>$rec</td>");
for ($i=0; $i<mysql_num_fields($this->resid); $i++)
echo("<td>".htmlentities($row[$i])."</td>");
echo("</tr>\n");
}
echo ("</table>");
}
function set_doerror($boolvalue)
{
$this->doerror = $boolvalue;
}
function mysql_db()
// Construktor
{
$this->connect();
}
}
$db = new mysql_db;
#=============Code==================
$server = "localhost";
$user = "xxxxx";
$pass = "xxxxx";
$datenbank = "votum_alex";
$ip = $REMOTE_ADDR;
$ip_proxy = $HTTP_X_FORWARDED_FOR;
$timestamp = time();
$zeitstempel = $timestamp;
$verbindung = mysql_connect($server,$user,$pass) or die ("Keine Verbindung möglich.
Prüfen Sie die Zugangsdaten oder wenden Sie sich an den Administrator.");
mysql_select_db($datenbank) or die ("Die Datenbank existiert nicht.
Prüfen Sie die Schreibweise oder wenden Sie sich an den Administrator.");
$dbh = mysql_connect($server, $user, $pass);
$db->query("select count(*) from vowahl where ip_proxy ='$proxytest'");
list($anzahl) = $db->data();
if ($anzahl>0)
{echo "Hoppla!
Solo se puede votar una vez!!";}
/*Die einzubauende Abfrage!!
$db->query("SELECT * FROM vowahl WHERE votenid=$votenid and ipadresse='$ip' and Zeit+INTERVAL 2 HOUR>NOW()");
if (!$db->data())
$db->query("INSERT INTO vowahl VALUES ('$votenid', '$antwortnr', '$ip', '$ip_proxy', NOW())");
**/
else{
if($ip_proxy == "")
$ip_proxy = "No tiene!";
$db->query("INSERT INTO vowahl VALUES ('$votenid', '$antwortnr', '$ip', '$ip_proxy', NOW())");
$zeitstempel = time ();
$datum = date ("d.m.Y - H:i:s",$zeitstempel);
echo "
<p align=\"center\"><font face=\"Arial\" size=\"4\" color=\"#6600FF\">";
echo "
";
echo "
";
echo "
";
echo "Gracias por su voto";
echo "
";
echo "Fecha Votacion: ";
echo $datum;
}
$ergebnis = mysql_query( "SELECT * FROM vowahl" );
$anz_nachher = mysql_num_rows( $ergebnis );
$timestamp = time ();
?>
#============Code=Ende==============
Gruß
