php-vineet Posted October 12, 2012 Share Posted October 12, 2012 have a look on code ....ajaxDATA.php this code work on my old server but after moving server on vps it return error.. Quote Link to comment https://forums.phpfreaks.com/topic/269378-getting-parse-error-syntax-error-unexpected-t_require-in-homexxxxxxxxxxxxajaxdataphp-on-line-1-after-moving-server/ Share on other sites More sharing options...
darkfreaks Posted October 12, 2012 Share Posted October 12, 2012 try changing the require to two dots. require('../wp-blog-header.php'); Quote Link to comment https://forums.phpfreaks.com/topic/269378-getting-parse-error-syntax-error-unexpected-t_require-in-homexxxxxxxxxxxxajaxdataphp-on-line-1-after-moving-server/#findComment-1384709 Share on other sites More sharing options...
PFMaBiSmAd Posted October 12, 2012 Share Posted October 12, 2012 (edited) The error is most likely because there is no white-space after the first opening <?php tag. edit: or after the comment/before the require() statement. Edited October 12, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/269378-getting-parse-error-syntax-error-unexpected-t_require-in-homexxxxxxxxxxxxajaxdataphp-on-line-1-after-moving-server/#findComment-1384710 Share on other sites More sharing options...
darkfreaks Posted October 12, 2012 Share Posted October 12, 2012 ^ that too should indent your code so it is more readable. <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ require ('./../../../wp-blog-header.php'); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'verify_code': if (!isset($_SESSION)) { session_start(); } if (isset($_SESSION['dcode'])) { if ($_GET['dcode'] == $_SESSION['dcode'][$_GET['postID']]) { echo 'Success:' . $_SESSION['durl']['postID']; } else { echo 'Failed: Wrong code entered.'; } } else { echo 'System is not working as expected.'; } break; case 'handleCookie': if (!isset($_SESSION)) { session_start(); } if (isset($_GET['task'])) { switch ($_GET['task']) { case 'addCookie': $_SESSION[$_GET['name']] = $_GET['value']; if (isset($_SESSION[$_GET['name']])) { echo 'Success'; } else { echo 'Failed'; } break; case 'readCookie': echo $_SESSION[$_GET['name']]; break; case 'deleteCookie': unset($_SESSION[$_GET['name']]); if (!isset($_SESSION[$_GET['name']])) { echo 'Success'; } else { echo 'Failed'; } break; } } break; case 'exportToCSV': $data = urldecode($_GET['data']); $fileName = "mobileComparison.csv"; if (isset($_GET['start'])) { unlink($fileName); } $fp = fopen($fileName, "a"); fwrite($fp, str_replace('\"', "\"", $data) . "\r\n"); fclose($fp); if (isset($_GET['end'])) { echo '<a href="'; bloginfo('template_directory'); echo '/' . $fileName; echo '">Download CSV File</a>'; } break; default: echo 'System failed to process your request.'; break; } } else { ?> <?php $k = 0; $temp = $wp_query; $wp_query = null; if (isset($_GET['brand']) || isset($_GET['meta_key'])) { if (!isset($_GET['meta_key'])) { $wp_query = new WP_Query('post_type=mobile&showposts=28&paged=' . $paged . '&brands=' . $_GET['brand'] . ''); } else { $metakeys = explode(",", $_GET['meta_key']); $getmetavalues = explode(",", $_GET['meta_value']); foreach($getmetavalues as $ck => $cv) { if ($cv == "" || $cv == " ") { unset($metavalues[$ck]); } } unset($metakeys['ecpt_operatingsystem']); $countMetakeys = count($metakeys) - 1; for ($i = 0; $i <= $countMetakeys - 1; $i++) { $metavalues[] = $getmetavalues[$i]; unset($getmetavalues[$i]); } sort($getmetavalues); foreach($getmetavalues as $key => $value) { if ($value == "" || $value == " ") { unset($getmetavalues[$key]); } } if (!is_null($getmetavalues[0]) || !is_null($getmetavalues[1])) { $metavalues[] = $getmetavalues; } foreach($metakeys as $randomkeys) { if ($randomkeys == "ecpt_operatingsystem") { $metacompare[] = "IN"; } else { if ($randomkeys == "ecpt_mop") { $metacompare[] = "BETWEEN"; } else { $metacompare[] = "LIKE"; } } } foreach($metakeys as $keyU => $valueU) { if ($valueU == null || $valueU == '' || $valueU == ' ') { unset($metakeys[$keyU]); } } foreach($metakeys as $keyU => $valueU) { if ((string)$keyU == "ecpt_mop") { $metaquery[] = array( 'key' => $metakeys[$keyU], 'value' => explode("-", str_replace(" ", "", str_replace("INR ", "", $metavalues[$keyU]))) , 'type' => 'numeric', 'compare' => $metacompare[$keyU] ); } else { if ($metakeys[$keyU] == "ecpt_operatingsystem") { $metakeys[$keyU] = "ecpt_osparent"; } $metaquery[] = array( 'key' => $metakeys[$keyU], 'value' => $metavalues[$keyU], 'compare' => $metacompare[$keyU] ); } } $showPosts = 28; if (isset($_GET['showPosts'])) { $showPosts = $_GET['showPosts']; } else { $showPosts = 28; } $arguments = array( 'post_type' => 'mobile', 'showposts' => $showPosts, 'paged' => $paged, 'brands' => $_GET['brand'], 'meta_query' => $metaquery ); $wp_query = new WP_Query($arguments); } } else { $wp_query = new WP_Query('post_type=mobile&showposts=28&paged=' . $paged); } if (!$wp_query->have_posts()) { echo '<h1>No Results Found.</h1>'; } $numPosts = 0; while ($wp_query->have_posts()): $wp_query->the_post(); $mobile_img = get_post_meta(get_post_meta($post->ID, "mobile_mobile-thumb-image_thumbnail_id", $single = true) , '_wp_attached_file', $single = true); $mobile_img_alt = get_post_meta(get_post_meta($post->ID, "mobile_mobile-thumb-image_thumbnail_id", $single = true) , '_wp_attachment_image_alt', $single = true); include "mobile-img.php"; ?> <?php if ($k % 4 == 0) { echo '<div class="clear"></div>'; } $numPosts++; ?> <div class="model-compare-block" id="model-compare-block<?php echo $numPosts; ?>"> <div class="model-preview"><center><a href="<?php the_permalink(); ?>"> <img id="model-image<?php echo $numPosts; ?>" src="<?php bloginfo('home'); echo '/wp-content/uploads/' . $mobile_img; ?>" alt="<?php echo $mobile_img_alt; ?>"> </a></center></div> <div class="model-name"><a id="model-name<?php echo $numPosts; ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div> <div style="display:none;" id="postID-<?php echo $numPosts; ?>"><?php echo $post->ID; ?></div> <div class="compare-btn" id="compare-btn<?php echo $numPosts; ?>"><center><a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/comare-btn.png" width="97" height="29" /></a></center></div> </div> <?php $k++; unset($mobile_img); unset($mobile_img_alt); endwhile; if (function_exists('wp_pagenavi')) { wp_pagenavi(); } $wp_query = null; $wp_query = $temp; ?> <div class="clear"></div> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/269378-getting-parse-error-syntax-error-unexpected-t_require-in-homexxxxxxxxxxxxajaxdataphp-on-line-1-after-moving-server/#findComment-1384711 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.