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

 

Link to comment
Share on other sites

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>");

?> 

Link to comment
Share on other sites

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";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.