Toon posts:

[MySQL/PHP] Query error

Pagina: 1
Acties:
  • 47 views sinds 30-01-2008

Verwijderd

Topicstarter
De output+ probleem:

Select Nickname, City, Country, Age, Sex FROM users WHERE FirstName='jj'
Warning: Supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\searchhandle.php on line 38

De code (database login gemasked natuurlijk):

<?
//Then the time has come to open the portal to our big bad databeast
$dbcnx = @mysql_connect ("localhost", "DreamworX", "TjZUZ4He");
if (!$dbcnx) {exit("<font color=#FFFFFF face=Verdana, Arial, Helvetica, sans-serif>Unable to connect to the database, please try again later</FONT>");}
else{
mysql_select_db("Chatpages");
//Ok let's handle the darn searchquerie
$SQL="Select Nickname, City, Country, Age, Sex FROM users WHERE ";
$SQLWhere="";
if ($FirstName!="") {$SQLWhere=$SQLWhere."FirstName='".$FirstName."'";}
if ($LastName!="") {if ($SQLWhere==""){$SQLWhere=$SQLWhere."LastName='".$LastName."'";} Else {$SQLWhere=$SQLWhere." and LastName='".$LastName."'";}}
if ($Nickname !=""){if ($SQLWhere==""){$SQLWhere=$SQLWhere."Nickname='".$Nickname."'";} Else {$SQLWhere=$SQLWhere." and Nickname='".$Nickname."'";}}
if ($City !="") {if ($SQLWhere==""){$SQLWhere=$SQLWhere."City='".$City."'";} Else {$SQLWhere=$SQLWhere." and City='".$City."'";}}
if ($StateProvince!=""){if ($SQLWhere==""){$SQLWhere=$SQLWhere."StateProvince='".$StateProvince."'";}Else{$SQLWhere=$SQLWhere." and StateProvince='".$StateProvince."'";}}
if ($Country!=""){if ($SQLWhere==""){$SQLWhere=$SQLWhere."Country='".$Country."'";} Else {$SQLWhere=$SQLWhere." and Country='".$Country."'";}}
//AgeCalculation
//$SQLAge="Select Nickname, Birthdate, CURRENT_DATE, (YEAR(CURRENT_DATE)-YEAR(Birthdate)) - (RIGHT(CURRENT_DATE,5)(RIGHT(Birthdate,5)) AS age FROM users;";
//$sqlageresult = mysql_query($SQLAge);
//$row=mysql_fetch_array($sqlageresult);
//$Age=["age"];
//WHERE addition for the age
if ($Gender!="Empty"){if ($SQLWhere==""){$SQLWhere=$SQLWhere."Gender='".$Gender."'";} Else {$SQLWhere=$SQLWhere." and Gender='".$Gender."'";}}
//AboutString Search
//Interests String Search
if ($MSNAddress!="") {if ($SQLWhere==""){$SQLWhere=$SQLWhere."MSNAddress='".$MSNAddress."'";} Else {$SQLWhere=$SQLWhere." and MSNAddress='".$MSNAddress."'";}}
if ($ICQUIN!="") {if ($SQLWhere==""){$SQLWhere=$SQLWhere."ICQNumber='".$ICQUIN."'";} Else {$SQLWhere=$SQLWhere." and ICQNumber='".$ICQUIN."'";}}
//search for values with picture
if (!isset($Picture)) {$Picture = "False";}
if ($Picture=="True"){$SQLWhere=$SQLWhere." and Picture=NOT NULL";}
//Order by..
//Show results, 20 per page, and make links for pages
$SQL="$SQL"."$SQLWhere";
print ("<table width=100% border=0>
<tr>");
print ("$SQL");
$result = mysql_query($SQL);
//OP DE REGEL HIERONDER LOOPT IE DUS STUK...
while ($row = mysql_fetch_array($result)){

print ("<td>".$row["Nickname"]."</td>");
print ("<td>".$row["City"]."</td>");
print ("<td>".$row["Age"]."</td>");
print ("<td>".$row["Gender"]."</td>");
}
// else{
// echo "No Results Found";
//}


//Ohh yah and not to forget...close the databeast connection
mysql_close($dbcnx);}
?>

Weet iemand hoe dat ik mijn resultaten wel op het scherm kan toveren?
Bij voorbaat dank

  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

or die(mysql_error())
en bekijk de quickguide voor de grap eens

Doet iets met Cloud (MS/IBM)


Dit topic is gesloten.