Jump to content

[SOLVED] Selct-Statement doesent´t work anymore


isar21

Recommended Posts

Hello,

without any known cause my Select-Statement seems to not work anymore (after four years without any trouble):

 

<?php

// Basic SELECT-Statement

$select = "SELECT DISTINCT ID, city, address, day_time, conntact, URL";

$from  = "FROM events";

$where  = "WHERE ID > 0";

$how = "ORDER BY city LIMIT 0, 30";

?>

 

Now I got this message:

 

Error: 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 'BY city LIMIT 0, 30' at line 1

 

In my php admin tool some content is still visbble some not, using the same Selct-Statement.

Everything concerning the DB seems to be o.k. all the data is there.

 

Any ideas what could be wrong there?

Thanks a lot.

 

Stephan

 

o.k., here comes the whole story:

 

<?php
$events = mysql_query($select . $from . $where . $how);
if (!$events) {
  echo("</table>");
  echo("<p>Fehler bei der Suche nach der Nachricht in der Datenbank!<br />".
       "Fehler: " . mysql_error() . "</p>");
  exit();
}


// permit breaks and paragraphs
	$address = ereg_replace("\r","",$address);
$address = ereg_replace("\n\n","<p></p>",$address);
$address = ereg_replace("\n","<br />",$address);

$day_time = ereg_replace("\r","",$day_time);
$day_time = ereg_replace("\n\n","<p></p>",$day_time);
$day_time = ereg_replace("\n","<br />",$day_time);



//print code to start the news table
print("<table width=\"560\"border=\"0\"bgcolor=\"#ffffff\"cellpadding=\"1\"cellspacing=\"2\">");

while ($event = mysql_fetch_array($events)) {
  echo("<tr valign='top'>\n");
  $id  = $event["id"];
  $city = htmlspecialchars($event["city"]);
  $address = htmlspecialchars($event["address"]);
  $day_time = htmlspecialchars($event["day_time"]);
  $conntact = htmlspecialchars($event["conntact"]);
  $URL = htmlspecialchars($event["URL"]);






// start table with results 

  print("<tr bgcolor='eeeeee' valign='top' halign='left'><td><font class='news-headline-2'>$city</font></td><td> </td><td>&nbsp</td></tr>\n");
  print("<tr valign='top' halign='left'><td class='news-content'>$address</td><td class='news-content'>$day_time<br><a href=\"http://$URL\" target=\"_blank\">$URL</a></td><td class='news-content'>$conntact</td></tr>\n");
  print("<tr valign='top' halign='left'><td> </td><td> </td<td> </td</tr>\n");
}
exit();

// closing table
print("</table>");

?> 

Somebody already showed me the solution. Some spaces were missing in the select statement.

The working code looks like that:

<?php 
  // SELECT-Statement
$select = "SELECT DISTINCT ID, city, address, day_time, conntact, URL ";
$from   = "FROM events ";
$where  = "WHERE ID > 0 ";
$how = "ORDER BY city LIMIT 0, 30";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.