HI, I've tried to install Drupal locally and get this error, could it be the mysql server that I'm using or drupal?

* user warning: 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 ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM drupal_menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in C:\Documents and Settings\Administrator\My Documents\Computing\htdocs\ecommercetotal\demos\drupal-6.2\includes\menu.inc on line 315.
* user warning: 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 ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM drupal_menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in C:\Documents and Settings\Administrator\My Documents\Computing\htdocs\ecommercetotal\demos\drupal-6.2\includes\menu.inc on line 315.

Comments

mickeyvip’s picture

Hello.

I was the same error and did not find any solutions. I am new to php, apache etc. so it took me 3 days to try and figure what was going on. And I did not understand anything...

I was about to give up, and then I was starring on the address of my Drupal "site to be" and the word "localhost" seemed not so right there. My computer is not in any domain, so I remebered that Apache wrote in log about setting host name to the computer's IP on the network.

I used the computer's local IP - 192.168... (NOT 127.0.0.1, though it could work, too) and the install went almost without a problem! It stacked on "update.php", so I just F5-refreshed it and everything went smooth from there.

Hope this is a solution to all our "sql on line 315" problems.

Cristian.Palmas’s picture

Hi mickeyvip.
I had the same problem with Drupal 6.2 and shared tables...

I did not understand completely what you said so I ask you whether you solved it simply changing the IP 127.0.0.1 into your computer IP for your domain....

The strange thing is that my first subdomain works perfectly, sharing the tables with the main installation, but the others brought me that error on line 315 on menu.inc during install...

~ Cristian Palmas ~

aethemba’s picture

Hi all,

This is my first time installing Drupal. I downloaded version 6.2 and installed the XAMMP package for PHP, Apache and MySQL.
I created a database and then I ran the install script. I first used localhost and I got the same error, line 315 menu.inc. After using my 'real' IP/install.php as the installation url I still get the same error.

What could it possibly be? Where do I need to look to discover what is going wrong?

Any help would be much appreciated.

Regards.

A

PS I have very little PHP/Webdevelopment experience (but I do have a programming background). Therefore, I could easily miss 'stupid' mistakes andobvious solutions.

fredriklyhagen’s picture

I have checked all threads on the SQL line 315 but still at a loss.
Get the following error msg:
___________________________________________
* user warning: 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 ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in /var/www/html/includes/menu.inc on line 315.
___________________________________________

Could somebody please write an "idiot's guide" to getting around this, as it seems a common issue?

/F

Not very impressed by Drupal installation files so far, it better kick ass compared to Joomla and Wordpress as their installations are a breeze.

VM’s picture

May help to diagnose if you could mention what version of MySQL you are using.

fredriklyhagen’s picture

Sorry!

MySQL 4.1.14 on doteasy.com hosting.
Manual: http://dev.mysql.com/doc/refman/4.1/en/index.html

Looks like I should find the solution in this section:
http://dev.mysql.com/doc/refman/4.1/en/select.html

This is the current (error) line 315:

if ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1))) {

Thanks,
F

fredriklyhagen’s picture

Any Drupal / MySQL experts who could have a look at this issue?
Being new to SQL and Drupal I have studied the manual and various forum posts but don't get any closer to resolution.

/F

brillyfresh’s picture

here's what i did:

the database configuration page during installation displayed a recommendation for me to increase PHP memory limit from 8M to 16M to avoid errors, so i opened /etc/php.ini, found memory_limit and changed the value, saved, restarted the web server, and voila! the menu.inc line 315 error was gone

you may have different results, but this worked for me

fredriklyhagen’s picture

Thanks for reply. I am on a hosted server so not so easy to restart. Will check with provider if they can support.

justageek’s picture

I am having same problem, and my memory limit is 100 mb, it isn't that , and I'm running mysql 4.1 as well. I have tried the latest stable php 4.x and the latest 5.x, does the exact same thing.

someone should solve this issue, if you google the error, you can find lots of web sites dying from the same error, so people are trying to use drupal 6.2 with no luck.

SteveBayerIN’s picture

I got the same error when setting up a multi-site install with table prefixes

Some steps I took that resolved the error:
I set the base url for my multi-site's child site's address. (just to be safe)
Gave a new table prefix (this fixed it)

For users who have the error on a new drupal install try removing the star from settings.php line that says:
* $db_prefix = 'main_';

into just
$db_prefix = 'main_';

jcross’s picture

Like everyone else here I had the "line 315" error while installing 6.3

I was able to complete the installation by deleting (aka "dropping") all of the tables (ie "emptying the database").
This is done through PHPMyAdmin.

I then hit refresh in the Drupal installation browser window and my installation completed successfully!

(This is a Dreamhost install for those who are interested.)

Good luck!

- Jonathan Cross

Incorrect info

There is a lot of incorrect info here (people shooting in the dark).
For example, removing the single star (as SteveJB suggests) does nothing at all.
It is within a comment block and is therefore ignored.

I also did not have to change settings.php.

I also did not have to do anything unusual with cookies or javascript in my Firefox3 browser.

Its a server-side error in which Drupal seems to create database tables which are somehow incompatible with itself.

Duplicate error:
http://drupal.org/node/269968

SteveBayerIN’s picture

ok if you want a word for word fix, it should be:

* To have all database names prefixed, set $db_prefix as a string:
 */
    $db_prefix = 'main_';
 /*
 * To provide prefixes for specific tables, set $db_prefix as an array.

for a new non-multi site install. What I did solved it more than once (with hard coding the base url,) how can you say it was shooting in the dark? There's a difference between incomplete (doing a fix hands on is much easier than documenting every step without error) and inaccurate.

I gather it is easier to edit settings.php without accessing mysql to drop or create a new database (despite duplication of tables with the prefixing method.)

There are 3 options here (dropping through mysql, creating a new database or prefixing) and yes a whole new database (ie. deleting and recreating the database instead of just the tables) is the best but not the only option available. I've done all three, prefixing seems to be the fastest way to fix work around the bug.

stevenghines’s picture

Emptying the database worked for me also. I was trying to install Drupal 6.9 on XAMPP in Windows Vista. Rather than use phpMyAdmin, I did the following on the command line (assuming your database is called "drupal":

DROP DATABASE drupal;
CREATE DATABASE drupal;
GRANT ALL ON drupal.* TO '<USERNAME>'@'localhost' IDENTIFIED BY <PASSWORD>;

Note that to get into the mysql command prompt, you need to start a windows command line and cd to XAMPP_INSTALL_DIR\mysql\bin and type mysql -uUSERNAME -pPASSWORD

SolaFide001’s picture

I have the same error on a fresh install of 6.3 with mysql Ver 14.12 Distrib 5.0.45 (bluehost.com). I've dropped all tables at least 10 times, added a prefix, and the memory is fine (I have several other domains on the same box with previous Drupal versions and no problems).

Since it seems the error is not there 100% of the time, I suspect that, while it has installed properly after some of the "fixes", we really haven't found the actual problem.

I'll keep dropping tables, creating new db's and new prefixes, but if I can't get one of these to work, I'll be choosing between an old version of Drupal or some other CMS... There's only so much time you can wait to get the thing installed...

bendenoz’s picture

Had the same problem, and it turned out my $cookie_domain variable in settings was somehow inconsistent.
Changed it to the site hostname, dropped and rebuilt the database and it solved the problem for me...

chaosprime’s picture

Based on this:

if ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1))) {

the problem is that that query is being executed when no placeholders have been found. You should be able to work around it by changing the line to:

if ($placeholders && ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1)))) {

The empty list of placeholders may cause other problems, but that should at least get you past this one.
--
Lost Souls: text based RPG
MUDseek: MUD gaming search

bisbell’s picture

That one worked for me. I would never have come up with that on my own.

jassi_1211’s picture

Hi. i tried this solution. The error on line 315 (of menu.inc) is gone, but there still seems to be some problem as the flow is not moving to the next step and i get a same page as earlier i.e. "Install site", without any error or warning message; and none of the menu links (steps) are clickable !! Did you also face the same problem, please suggest a solution

TheUser’s picture

Hihu,

i got the same error and a easy solution for it. Just activate Cookis in your browser ...

Frank Steiner’s picture

Same here. I was using Opera and it was not enough to enable cookies for my specific drupal server. I had to enable cookies in general, for all sites, then drop and recreate my drupal table in mysql. Then installation went fine.

After the installation I could disable cookies in the global settings again (and just enable cookies for the drupal server in the per-site settings).

jassi_1211’s picture

I tried all the solutions mentioned in this discussion. The line 315 error is gone, but the flow is still stuck up in the "Install site" step and it is not move ahead. As i said, error on line 315 is solved, I am not getting any new error, but something is wrong due to which control is not moving ahead. I am trying to install Drupal 6.6 with MySQL 5.0, Apache 2.2, PHP 5.1. One more thing, is the Drupal team sleeping or something !!! When so many people are having same problem, and still there is no concrete solution to it, what the hell, its time for drupal team to take this seriously and provide a reliable solution to this rubbish problem !!!

angelcar’s picture

Have found solution.

It is ugly, but I don't know why drupal so lol :)

You need to fix two lines at two files.

1. includes/menu.inc, line 315, add $placeholders && :

if ($placeholders && $router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1))) {

2. includes/batch.inc, line 15, add !:
if (isset($_REQUEST['id']) && $data = db_result(db_query("SELECT batch FROM {batch} WHERE bid = %d AND token != '%s'", $_REQUEST['id'], drupal_get_token($_REQUEST['id'])))) {

aczook’s picture

After beating my head in with a hammer for the last five (or so) hours, I can add one more possible source of this (and many other) problem(s). If you are using Dreamweaver to put the drupal files to the server ... STOP it's killing the source and making changes. Just use a regular FTP client. Dreamweaver is too smart for it's own good and takes liberties with the code especially if you change the folder name from the folder in the archive (drupal-6.8) to another folder name (drupal-6_8 - my server does not allow .ext) using the Dreamweaver interface. If you do this do not allow it to "update" other files. But, I strongly recommend not using it at all. This is just another thing to try if you have tried everything else in this thread (like I did - I did find some of these thing useful) and it was the fix for my case.

jjlillo’s picture

Hi angelcar!

I have modified this two lines you said. Now I don't have the error, but the installation process is stopped (like a bucle..) at step "Install site".

Do you have some idea please?

thanks

reigne’s picture

Okay, I've taken the suggested changes and I'm still stuck -

VM’s picture

it may help to start a new thread explaining the problem as this thread is outdated and hacking core shouldn't be necessary.

bcobin’s picture

This worked for me. I "upgraded" to MAMP 1.8.1 and was locked out of a bunch of development sites; I'm trying to reinstall sites in the hopes they'll work.

sunyata’s picture

this solution worked for me to get past install but I am hitting a user access problem which I have commented at http://drupal.org/node/481386#comment-2068696

I have reverted the fixes and I am still seeing my user access problem.

guignonv’s picture

I had the same error message (user warning: 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 ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM drupal_menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in XXX\includes\menu.inc on line 315.)

I tried the various fixes/workarrounds provided here but nothing helped. I guess this error message doesn't really point out the real background problem. In my case, it was because I was installing my drupal site from the "public" URL but the site was stored on another server using a proxypass (http server settings). Basically, I unzipped drupal on a server "foo" while the site was supposed to be accessed from the server "bar". I tried to install/configure drupal using the "http://bar/drupal/" installation script but I got the "famous" error. Then I installed it from "http://foo/drupal/" and it worked but I couldn't login from "http://bar/drupal/". So I modified settings.php and set up the appropriate values (base URL, cookies, proxyreverse,...) *after* the installation process and it appears to work just fine now.

So if you are installing drupal on a server that might be behind other servers, I suggest you use the URL of the server where drupal is really on (using the IP address maybe?) and then update your settings.php according to your needs.

Note: this is _not_ a "general" fix since the error message we are talking about can appear for various reasons (each one having its own *fix*).

Valentin Guignon, Bioversity International

joric’s picture

The problem is really is in the cookies. And it happened to me when I used my own DNS server and naming.

Just use ANOTHER BROWSER (like, IE instead of Firefox) on this step and it'll go as planned.

Further it arrives when you can't login to your own site.
Problem is somehow connected with Firefox 3 (and, maybe with other firefox versions too).

You have to comment out lines in a bootstrap.inc marked with "-":

// Per RFC 2109, cookie domains must contain at least one dot other than the
// first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
-if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
- ini_set('session.cookie_domain', $cookie_domain);
-}
-session_name('SESS'. md5($session_name));

For a strange reason it fixes the problem.

cpill’s picture

I was doing a multi-site install with a specialised install profile. I'd thought it had to be one of the modules being auto-installed, then I thought it was the shared tables. Turned out I had a bad value in the settings.php file for the $cookie_domain value (i'd copied the settings file from another site which had it set). Solved the problem.

I guess changing the browser might have helped as the cookies would have been different. Nasty little bug to hunt down. GUess Drupal should check all the settings.php values before accepting them, as well as the admin... :)

lungten’s picture

Thank you joric, this fix worked for me too. Man, its been days I've been trying almost everything mentioned here and in other related threads.

Details:
Web Host: FeeBSD/Apache 2.2/PHP 5.3/MySQL 5.1
Dupal: 6.16
Browser: Firefox 3.6

I am using Linux and Ff is my only web browser, so I didn't get to try installing drupal from an IE but today I did and viola! It worked.
Now, back in Ff, I could not login. I have my cookie settings in Ff OK but I wasn't getting any cookies from my new site into Ff.

I am wondering if this is a Ff bug or something else. Any way I am happy for now.

reigne’s picture

Okay, I've taken the suggested changes and I'm still stuck -

I go to install.php
Choose Language (I click English)

Then it shows
(checked) Choose language
(checked) Verify requirements
(checked) Set up database
Install site
Configure site
Finished
I cannot move past the step Install Site as there is nothing to do (it's blank below "HOME")

It 'seems' to be cookie problems but I really have no idea. I've followed all of the steps/suggestions above...have searched for almost 2 days for a solution...

Any more suggestions? (I'm not using dreamweaver)

huckleberry_finn’s picture

I've run in to this bug recently while trying to install Drupal running on Xampp onto a USB key under windows xp. For me I'd first experience the timeout message, then a page that looks like sql problems before finally getting a Drupal page showing the original error messages. I'm guessing that my problem was a bad install caused initially by the timeout as it takes longer to talk to the USB stick. I tried the advice for the DB erase but that only meant that I'd go through the entire process again ending up back where I started. To solve the problem I performed the following steps however they may be overkill...

1.) Increased the php timeout values in php.ini
2.) Dropped the contents of the current DB.
3.) Made a fresh install of drupal in xampp's htdocs folder.
4.) Stopped acache & mysql and double checked nothing funny was still running with task manager
5.) Restarted apache & mysql with the xampp_start.exe command
6.) Directed the browser (firefox 3.6) to http://localhost/drupal2

From here the install process continued smoothly.

glyndon’s picture

When installing today on a host (other than the one where the browser is running) I was also getting the 315-of-death.

However, just yesterday I installed with no problem on a different host, and it occurred to me that when doing so I referred to it in my browser as 'localhost' because I was using SSH and port-forwarding to access its webserver.

So I changed my connection to the problem install to use port-forwarding (so I could refer to it as 'localhost' in the browser), and the install ran successfully.

To my thinking, there's a miscoded reference to the Drupal host's name somewhere, and it's presuming you are browsing to 'localhost' when you may not be.

HTH, somehow.

candygirl777’s picture

is to delete the database and create a new one. I had problems with a subdomain, getting the syntax-line 315 error when trying to install, and thought it was a problem on the host side. Then I accidentally deleted the domain files with the subdomain, requiring to start both over from scratch. However this time, the subdomain worked without a hitch, but the domain gave me the line 315 error! I deleted the database on the domain, created a new one, and it worked!
Something else that is weird is that sometimes the settings.php file is copied for me, and sometimes it isn't. It may have something to do with this problem, because I didn't have to copy the settings file with the subdomain, but I was prompted to do it with the domain. Go figure.

It's nice to know I'm not the only one frustrated. I put a ticket in with my host, and will let everyone know if they give me an answer. But for now, all I can say is, unfortunately, sometimes you have to start over completely from scratch!

candygirl777’s picture

duplicate posting

candygirl777’s picture

dup posting

candygirl777’s picture

dup posting

candygirl777’s picture

dup posting

candygirl777’s picture

dup posting

candygirl777’s picture

dup posting

candygirl777’s picture

duplicate posting - I apologize for all the duplicate posts on this thread - it kept timing out so I didn't realize the posts actually did go through!

marcocuyt’s picture

Having read a million threads that were not able to solve my problem (apparently very common practice in Drupal world), I have found the solution for my situation.
I'm starting to believe that there are a couple of variations of problems that can cause the same error message

In my case, it was a server configuration error and the hosting company has helped me by putting a php.ini in my public_html folder with 1 sentence: "session.save_handler = user"
That's all...everything worked fine with that single action

max.dev’s picture

This problem occurred to me because I accidentally clicked the "Save.." button twice during the "Setup Database" step.

I fixed the issue by deleting all DB tables from phpMyAdmin, then all the files from my Drupal directory and re-starting the installation process.

Brn’s picture

user warning: 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 ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in /var/..../html/..../includes/menu.inc on line 315.

The problem was in cookies for me too.

I had disabled cookies in Firefox, for all the sites. I resolved the problem by enable cookies for the domain used for the installation of drupal.

runinout’s picture

As others have noted, dropping the database and then creating again works. Unfortunately, I can't offer any insight into why/how.

- Meech