Ich bekommen bei einer MYSQL Anweisung immer obiges Problem. Wenn ich den generierten SQL Code in phpmyadmin packe, wird dieser sauber ausgeführt. Kann mir jemand sagen wo das Problem ist?
Hier der komplette Code:
Die Ausgabe kann man sich hier ansehen:
http://bit.ly/PDy8gy
Hier der komplette Code:
PHP-Code:
<?php
# function wpShowPosts($zwp_product_name, $zwp_manu_name, $zwp_cat_name) {
$zwp_product_name = 'Shimano, Kette, Dura Ace, 10-fach, CN-7801';
$zwp_manu_name = 'Shimano';
$zwp_cat_name = 'Fahrradkette';
$zwp_regex = "/[,.-]/";
$zwp_search_string = '';
$zwp_product_name = preg_replace ($zwp_regex,'',$zwp_product_name);''; # Shimano HG-50 Kette
$zwp_string = $zwp_product_name.' '.$zwp_manu_name.' '.$zwp_cat_name;
$zwp_words = explode(" ", $zwp_string);
$zwp_words = array_values(array_unique($zwp_words));
$first = '';
$zwp_search_string = '';
foreach($zwp_words as $f ){
if ($first <> '') { $zwp_search_string = $zwp_search_string . " OR "; } else { $first = 'X'; }
$zwp_search_string = $zwp_search_string . " wp_terms.name LIKE \"%".trim($f)."%\"";
}
$mysqlc = mysql_connect("XXX", "XXX", "XXX");
$myquery = 'SELECT DISTINCT wp_term_relationships.object_id AS id
FROM ( wp_term_taxonomy INNER JOIN wp_term_relationships
ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id )
INNER JOIN wp_terms
ON wp_terms.term_id = wp_term_taxonomy.term_id
WHERE ( '.$zwp_search_string.' );';
echo $myquery;
$resultc = mysql_query($myquery);
echo $mysqlerror();
$zwp_id = '';
while( $row = mysql_fetch_array($resultc) ) {
$zwp_id = $zwp_id . "," . $row['id'];
}
$myquery2 = 'SELECT DISTINCT post_title, post_name, post_content
FROM
wp_posts
WHERE
id IN ('. $zwp_id .')
AND post_status = \"publish\"
AND post_type = \"post\"
ORDER BY
RAND()
LIMIT
0, 3;';
#echo $myquery2;
$resultc2 = mysql_query($myquery2);
while( $row2 = mysql_fetch_assoc($resultc2) ) {
$zwp_return = $zwp_return . '<h3><strong><a href="http://www.XXX.de/XXX/' . $row2['post_name'] . '">'. $row2['post_title'] . '</a></h3>';
}
# return $zwp_return;
# }
#$output = wpShowPosts('Shimano, Kette, Dura Ace, 10-fach, CN-7801', 'Shimano', 'Fahrradkette');
#echo $output;
?>
http://bit.ly/PDy8gy
Kommentar