Avatar billede ejay Novice
19. august 2004 - 08:44 Der er 21 kommentarer og
1 løsning

Kan ikke forstå fejlen

jeg har dette i mit script:

$result = mysql_query("Select * from plmatchdata where mail_sendt = 'Nej' && homescore is not NULL && awayscore is not NULL") or die (mysql_error());
while($row = mysql_fetch_array($result)) {


men får denne fejl:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'where mail_sendt = 'Nej' && homescore is not NULL && awayscore


Nogen der kan hjælpe med den?
Avatar billede fennec Nybegynder
19. august 2004 - 08:48 #1
"Select * from plmatchdata where mail_sendt = 'Nej' AND homescore is not NULL AND awayscore is not NULL"
Avatar billede ejay Novice
19. august 2004 - 09:03 #2
Får denne fejl nu :

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'where mail_sendt = 'Nej' AND homescore is not NULL AND awayscor
Avatar billede eagleeye Praktikant
19. august 2004 - 09:22 #3
hvilken version bruger du?

Hvilken type er kolonnen mail_sendt?
Avatar billede fennec Nybegynder
19. august 2004 - 09:33 #4
Mærkeligt.....

Så må vi til at forsøge os frem. Du skal have afprøvet disse:

"Select * from plmatchdata"
"Select * from plmatchdata where mail_sendt = 'Nej'"
"Select * from plmatchdata where homescore is not NULL"
"Select * from plmatchdata where awayscore is not NULL"

En eller flere af disse burde fejle. Jeg vil gætte på mail_sendt.
Avatar billede ejay Novice
19. august 2004 - 09:33 #5
jeg kører
phpMyAdmin 2.5.4
MySQL 4.0.18

kolonnen mail_sendt er : enum('Ja', 'Nej')
Avatar billede morteeart Nybegynder
19. august 2004 - 09:53 #6
øhh... is not ?

prøv med

"Select * from plmatchdata where mail_sendt = 'Nej' AND homescore!='NULL' AND awayscore!='NULL' "
Avatar billede eagleeye Praktikant
19. august 2004 - 09:55 #7
Prøv med ; tilsidst:

"Select * from plmatchdata where mail_sendt = 'Nej' && homescore is not NULL && awayscore is not NULL;"
Avatar billede ejay Novice
19. august 2004 - 10:08 #8
morteeart:
får denne fejl nu:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'where mail_sendt = 'Nej' AND homescore!='NULL' AND awayscore!='
Avatar billede ejay Novice
19. august 2004 - 10:10 #9
eagleeye: stadig fejl.
Avatar billede ejay Novice
19. august 2004 - 10:11 #10
sådan her ser mail_sendt ud i mysq.

`mail_sendt` enum('Ja','Nej') NOT NULL default 'Nej',
Avatar billede eagleeye Praktikant
19. august 2004 - 10:11 #11
PRøv

"Select * from plmatchdata where mail_sendt = 'Nej' AND homescore IS NOT NULL AND awayscore IS NOT NULL;"

Når man har Null skal man bruge IS NULL eller IS NOT NULL.
Avatar billede ejay Novice
19. august 2004 - 10:12 #12
og sådan her ser script ud:

<? }

function SendAutoMails($email) {
if ($email == "Ja") {
$number = 0;
$result = mysql_query("Select * from plmatchdata where mail_sendt = 'Nej' && homescore is not NULL && awayscore is not NULL;") or die (mysql_error());
while($row = mysql_fetch_array($result)) {
$result2 = mysql_query("Select * from plpredictiondata where matchid = '". $row["matchid"] ."'") or die (mysql_error());
while($row2 = mysql_fetch_array($result2)) {
$result3 = mysql_query("Select * from pluserdata where userid = '". $row2["userid"] ."'") or die (mysql_error());
$row3 = mysql_fetch_array($result3);
$text = "<html>
<head>
<title>Kampe spillet</title>
<link rel=\"stylesheet\" href=\"http://www.tipkampen.dk/common.css\" type=\"text/css\">
</head>
<body class=\"MAIN\"><script type='text/javascript'><!--
google_ad_client = 'pub-0589142578060587';
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = '468x60_as';
google_ad_channel ='';
google_color_border = '687F99';
google_color_bg = '687F99';
google_color_link = '000000';
google_color_url = 'ffffff';
google_color_text = '000000';
//--></script>
<script type='text/javascript'
  src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script><br>
<p>Her kan du se hvad resultatet blev, og hvad du tippede på kampen:</p>";




    $text .= "<table class=\"STANDTB\">\n";
    $text .= "<tr>\n";
    $text .= "<td class=\"TBLHEAD\" colspan=\"6\" align=\"center\"><font class=\"TBLHEAD\">$FixturesResults</font></td>\n";
    $text .= "</tr>\n";
    $text .= "<tr>\n";
    $text .= "<td width=\"80\" align=\"center\" class=\"TBLHEAD\"><font class=\"TBLHEAD\">$Date</font></td>\n";
    $text .= "<td width=\"150\" align=\"center\" class=\"TBLHEAD\"><font class=\"TBLHEAD\">$Home</font></td>\n";
    $text .= "<td align=\"center\" class=\"TBLHEAD\"><font class=\"TBLROW\">G</font></td>\n";
    $text .= "<td align=\"center\" class=\"TBLHEAD\"><font class=\"TBLROW\">v</font></td>\n";
    $text .= "<td align=\"center\" class=\"TBLHEAD\"><font class=\"TBLROW\">G</font></td>\n";
    $text .= "<td align=\"center\" class=\"TBLHEAD\"><font class=\"TBLROW\">Tip G</font></td>\n";
    $text .= "<td align=\"center\" class=\"TBLHEAD\"><font class=\"TBLROW\">v</font></td>\n";
    $text .= "<td align=\"center\" class=\"TBLHEAD\"><font class=\"TBLROW\">Tip G</font></td>\n";
    $text .= "<td width=\"150\" align=\"center\" class=\"TBLHEAD\"><font class=\"TBLHEAD\">$Away</font></td>\n";
    $text .= "</tr>\n";
    // First loop. Used to get all the matches
$result4 = mysql_query("SELECT * FROM plmatchdata order by matchdate where mail_sendt = 'Nej' && homescore is not NULL && awayscore is not NULL;") or die (mysql_error());
    while ($row4 = mysql_fetch_array($result4)) {
$result5 = mysql_query("Select * from plpredictiondata where matchid = '". $row4["matchid"] ."'") or die (mysql_error());
$row5 = mysql_fetch_array($result5);
      $matchid = $row4["matchid"];
      $hometeam = stripslashes($row4["hometeam"]);
      $awayteam = stripslashes($row4["awayteam"]);
      $homescore = $row4["homescore"];
      if ($homescore == null) {
        $homescore = "&nbsp;";
      }
      $awayscore = $row4["awayscore"];
      if ($awayscore == null) {
        $awayscore = "&nbsp;";
      }
      $date = $row4["matchdate"];
      $datetext = GetDateFromDatetime($date);

      $text .= "<tr>\n";
      $text .= "<td class=\"TBLROW\"><font class=\"TBLROW\"><a href=\"showpredictionsformatch.php?sid=$SID&matchid=$matchid&date=$date\">$datetext</a></font></td>\n";
      $text .= "<td class=\"TBLROW\"><font class=\"TBLROW\">$hometeam</font></td>\n";
      $text .= "<td align=\"CENTER\" class=\"TBLROW\"><font class=\"TBLROW\">$homescore</font></td>\n";
      $text .= "<td align=\"CENTER\" class=\"TBLROW\"><font class=\"TBLROW\">v</font></td>\n";
      $text .= "<td align=\"CENTER\" class=\"TBLROW\"><font class=\"TBLROW\">$awayscore</font></td>\n";
      $text .= "<td align=\"CENTER\" class=\"TBLROW\"><font class=\"TBLROW\">". $row5["homescore"] ."</font></td>\n";
      $text .= "<td align=\"CENTER\" class=\"TBLROW\"><font class=\"TBLROW\">v</font></td>\n";
      $text .= "<td align=\"CENTER\" class=\"TBLROW\"><font class=\"TBLROW\">". $row5["awayscore"] ."</font></td>\n";
      $text .= "<td class=\"TBLROW\"><font class=\"TBLROW\">$awayteam</font></td>\n";
      $text .= "</tr>\n";
    }
    $text .= "</table>\n";


$text .= "På gensyn<br><br>www.Tipkampen.dk
</body>
</html>";
// To send HTML mail, you can set the Content-type header.
//$headers  = "MIME-Version: 1.0\r\n";
// additional headers
$headers = "From: Tipkampen.dk <no-reply@tipkampen.dk>\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
//$headers .= "Cc: birthdayarchive@example.com\r\n";
//$headers .= "Bcc: birthdaycheck@example.com\r\n";
@mail($row3["username"] ." <". $row3["email"] .">", "Kamp spillet",$text,$headers);
$number = $number+1;
}
mysql_query("update $dbaseMatchData set mail_sendt = 'Ja' where matchid = '". $row["matchid"] ."'") or die (mysql_error());
} ?>
<table width="100%">
  <tr>
    <td colspan="3" align="center" class="TBLROW">
      <font class="TBLROW">
<?=$number?> mails blev sendt
      </font>
    </td>
  </tr>
  </table>
<?php
  } else {
?>
  <form method="POST" action="index.php?cmd=sendautomails">
  <table width="100%">
  <tr>
  <td align="CENTER" class="TBLHEAD">
  <font class="TBLHEAD">
  Send email
  </font>
  </td>
  <td align="center" class="TBLROW">
  <font class="TBLROW">
  <input type="radio" name="email" value="Ja">Ja
  <input type="radio" name="email" value="Nej" checked="checked">Nej
  </font>
  </td>
  <td align="center" class="TBLROW">
  <font class="TBLROW">
  Sender mail til alle de brugere der har tippet på en eller flere kampe, som er blevet spillet.
  </font>
  </td>
  </tr>
<tr>
<td colspan="3" align="CENTER">
<font class="TBLROW">
<input type="SUBMIT" name="Send" value="Send mails">
</td>
</tr>
  </table>
  </form>
<? }
}
?>
Avatar billede ejay Novice
19. august 2004 - 10:15 #13
eagleeye:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'where mail_sendt = 'Nej' AND homescore IS NOT NULL AND awayscor
Avatar billede fennec Nybegynder
19. august 2004 - 10:19 #14
kører mail_sendt evt på index'et i stedet for value???

"Select * from plmatchdata where mail_sendt = 2 AND homescore is not NULL AND awayscore is not NULL"
Avatar billede ejay Novice
19. august 2004 - 10:22 #15
oki der tabte du mig fennec.

jeg er ikke en haj til php, det er en jeg kender der har lavet scriptet og han er selvfølglig på ferie *G*
Avatar billede ejay Novice
19. august 2004 - 10:27 #16
har fundet ud af fejlen ligger her:

$result4 = mysql_query("SELECT * FROM plmatchdata order by matchdate where mail_sendt = 'Nej' && homescore IS NOT NULL && awayscore IS NOT NULL") or die (mysql_error());
    while ($row4 = mysql_fetch_array($result4)) {
Avatar billede eagleeye Praktikant
19. august 2004 - 10:29 #17
er du sikker på hvor fejlen er og ikke her

$result4 = mysql_query("SELECT * FROM plmatchdata order by matchdate where mail_sendt = 'Nej' && homescore IS NOT NULL && awayscore IS NOT NULL") or die (mysql_error());
    while ($row4 = mysql_fetch_array($result4)) {

Man skal havde Where før order by :

$result4 = mysql_query("SELECT * FROM plmatchdata where mail_sendt = 'Nej' && homescore IS NOT NULL && awayscore IS NOT NULL order by matchdate ") or die (mysql_error());
    while ($row4 = mysql_fetch_array($result4)) {
Avatar billede ejay Novice
19. august 2004 - 10:34 #18
eagleeye: se så kom vi lidt frem. men får denne fejl nu:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'set mail_sendt = 'Ja' where matchid = '37'' at line 1
Avatar billede ejay Novice
19. august 2004 - 10:36 #19
det må være denne linje:

mysql_query("update $dbaseMatchData set mail_sendt = 'Ja' where matchid = '". $row["matchid"] ."'") or die (mysql_error());
Avatar billede eagleeye Praktikant
19. august 2004 - 10:37 #20
Ja, prøv at rette den fra:

mysql_query("update $dbaseMatchData set mail_sendt = 'Ja' where matchid = '". $row["matchid"] ."'") or die (mysql_error());

Til:
mysql_query("update plmatchdata set mail_sendt = 'Ja' where matchid = '". $row["matchid"] ."'") or die (mysql_error());
Avatar billede ejay Novice
19. august 2004 - 10:40 #21
Den sender mails ud men den siger stadig den fejl med:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'set mail_sendt = 'Ja' where matchid = '37'' at line 1
Avatar billede ejay Novice
19. august 2004 - 10:42 #22
Sådan nu virker det sku :) takker eagleeye. og alle jer andre der prøvede og hjælpe.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester