Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I recently installed WordPress on IIS 7 and wired it up to SQL Server 2008R2. The installation went fine, then after a short while of testing, new new posts could no longer be seen in any category (or any posts for that matter).

In the admin menu, under posts, I see that there are six published posts "Published (6)". However the list below this is empty. Also trying to view these on the site, by selecting the category returns

Nothing Found

Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.

I have re-installed the database, overwrote the PHP/SQL files and re-installed WP. Problem persists.

I tried the Settings/Permalinks suggestions here and. No change.

The suggestions here relate to not being able to write to the .htaccess file. Not an issue for me, and I am not seeing the error of not being able to save. (To verify, I saved, exited, navigated to the same Permalinks page and my settings were saved).

I even set the Permalinks to to default and removed the Web.config rewrite rules:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="wordpress" patternSyntax="Wildcard">
            <match url="*"/>
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                </conditions>
            <action type="Rewrite" url="index.php"/>
        </rule>
     </rules>
    </rewrite>
  </system.webServer>
</configuration>

No change. (Added them back in).

I set SAVEQUERIES=TRUE in wp-config.php and I can see the contents of some of the posts in the log file.

ie. Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack...

No change.

I have seen other posts that refer to changing some security settings as the system may be detecting a potential SQL injection attack. However those posts are related to an Apache-related installation, and cannot locate any references in my version.

Some assistance with this would be greatly appreciated.

Thanks.

-- UPDATE --

I retried this with WP 3.21 - same issue, and have been monitoring Windows/Temp/php53_errors.log. The only issue I see coming up is

[07-Mar-2012 21:00:51 UTC] WordPress database error 42000 : [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near 'wp_users'. for query SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE ''wp_users'' made by display_setup_form, pdo_wpdb->query, pdo_wpdb->_post_query, pdo_wpdb->print_error

share|improve this question
    
I suspect your problems lie in the replacement wpdb you have to work with SQL Server, because internally, WP generates SQL that is pretty specific to MySQL. –  Dougal Campbell Mar 24 '12 at 2:58
    
How are you getting this to work with SQL Server? WP doesn't connect to that by default (as Dougal points out) and we can't help with systems we don't know about ... –  EAMann Apr 11 '12 at 21:48
    
There are several ways to combine WordPress with SQL Server: google.ca/… –  ElHaix Apr 12 '12 at 13:55
add comment

1 Answer

Analysing the Error

WordPress database error 42000 : [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near 'wp_users'. for query SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE ''wp_users'' made by display_setup_form, pdo_wpdb->query, pdo_wpdb->_post_query, pdo_wpdb->print_error

…reads as:

SELECT TABLE_NAME 
FROM INFORMATION_SCHEMA.TABLES 
    WHERE TABLE_NAME 
    LIKE ''wp_users'' 

Your Problem

It seems you got constants in your query string. And those constants are simply not getting triggered.

How to do it the right way

Note: You can't put constants inside a string. You'll have to do:

$wpdb->query( $wpdb->prepare( "
        SELECT %s
        FROM %s
            WHERE %s
            LIKE %s
    " ),
    TABLE_NAME,
    INFORMATION_SCHEMA,
    TABLE_NAME,
    like_escape( $wpdb->users )
);

This ↑ is a) save and b) the correct way to do it.

The other missunderstanding

The following…

display_setup_form
pdo_wpdb->query
pdo_wpdb->_post_query
pdo_wpdb->print_error

…seems to come from wrong function naming.

The right way to call table names and $wpdb (WP_Query) functions:

The object $pdo_wpdb->query likely doesn't exist. You'll have to call the global $wpdb; at first. Then you'll have access to a number of things, like the native query functions.

# Example:
global $wpdb;
// The prefix you set inside your wp-config.php file
echo $wpdb->prefix;
// Default tables:
print_r( $wpdb->users );
print_r( $wpdb->options );
// Custom tables:
print_r( "{wpdb->prefix}your_table_name" );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.