我已经看过其他人的问题,但看不到任何相同的内容,所以如果我错过了一个就道歉。
我在开发它的同时在一个子目录中创建了一个站点,然后将其移动到根目录,将其移动到根目录,通过php停止工作访问MySQL数据库。它停止的特定代码行是
$pdo=new PDO("mysql:dbname=NAME;host=127.0.0.1","USERNAME","PASSWORD");
一旦脚本移动到根目录外的单个目录,该脚本就可以正常工作。任何想法可能是什么问题?
索引
<!DOCTYPE html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Raleway:600,500,400' rel='stylesheet' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link type="text/css" rel="stylesheet" href="/assets/css/ProtoStyle_1.css"/>
<?php
require_once('./php/autoloader.php');
$feed = new SimplePie('http://mywebsite.eu/blog/feed');
function returnImage ($text) {
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
$pattern = "/<img[^>]+\>/i";
preg_match($pattern, $text, $matches);
$text = $matches[0];
return $text;
}
function scrapeImage($text) {
$pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/';
preg_match($pattern, $text, $link);
$link = $link[1];
$link = urldecode($link);
return $link;
}
?>
</head>
<?php flush(); ?>
<body onresize="setFontSize()" >
<div id="kvh_page">
<div id="kvh_header"><?php include("nav-bar.html"); ?></div>
<div id="kvh_content">
<div id="kvh_latestproject">
<div class="kvh_screen" >
<div class="kvh_page1">
<img src="/assets/images/balloons.png"/>
<h1>Current Project</h1>
</div>
<div class="kvh_page2">
<img src="/assets/images/left-right.jpg"/>
<h1>Left/Right</h1>
<h2>Left/Right is a mobile app designed to push your reaction speed to the limit.</h2>
<a href="/projects/leftright"><button type="button">More</button></a>
</div>
</div>
</div>
<div id="kvh_latestblog">
<div>
<div class="kvh_screen" >
<div class="kvh_page1">
<img src="/assets/images/road.png"/>
<h1>Latest Blog Post</h1>
</div>
<?php $item = $feed->get_item();
$Description = $item->get_description();
$image = returnImage($Description);
$Description = str_replace($image, "", $Description);
$image = scrapeImage($image); ?>
<div class="kvh_page2" style="background-image: url('<?php print $image; ?>')">
<span class="kvh_textmask">
<h1><?php print $item->get_title(); ?></h1>
<h2><?php print $Description; ?></h2>
<?php $author = $item->get_author(); ?>
<h3>Posted on <?php print $item->get_date('j F, Y'); ?> by <strong><?php print $author->get_name(); ?></strong></h3>
<a href="<?php print $item->get_permalink(); ?>"><button type="button">Read more</button></a>
</span>
</div>
</div>
</div>
</div>
<div id="kvh_latestresource">
<div>
<div class="kvh_screen" >
<div class="kvh_page1">
<img src="/assets/images/rain.png"/>
<h1>Thing of the day</h1>
</div>
<?php include("gethomestuff.php"); ?>
<!--<div class="kvh_page2" style="background-image: url('/assets/images/MangaDice.png')">
<span class="kvh_textmask">
<h1>This is the name of the thing</h1>
<h2>- Category</h2>
<a href="#"><button type="button">Check it out</button></a>
</span>
</div>-->
</div>
</div>
</div>
</div>
</div>
<?php include("footer.php"); ?>
<script src="/assets/scripts/proto1.js"></script>
</body>
</html>
gethomestuff
<?php
try {
$pdo=new PDO("mysql:dbname=NAME;host=127.0.0.1","USERNAME","PASSWORD");
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$statement=$pdo->prepare("SELECT * FROM DailyStuff limit 1");
$statement->execute();
$results=$statement->fetchAll(PDO::FETCH_ASSOC);
foreach($results as $row)
{
if(strlen($row['Image']) < 10)
echo '<div class="kvh_page2">'. PHP_EOL;
else echo '<div class="kvh_page2" style="background-image: url(\''. $row['Image'] . '\')">'. PHP_EOL ;
echo '<span class="kvh_textmask">'. PHP_EOL . '<h1>'. $row['Name'].'</h1>'. PHP_EOL . '<h2>- '. $row['Category'] .'</h2>' . PHP_EOL .'<a href="'.$row['Link']. '"><button type="button">Check it out</button></a>'. PHP_EOL .'</span>'. PHP_EOL .'</div>' . PHP_EOL;
}
?>
答案 0 :(得分:0)
您应该始终检查对数据库的所有调用的结果,以便将该行代码更改为
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.example.com"]];
request.HTTPMethod = @"POST";
request.HTTPBody = body;
[request setValue:@"someValue" forHTTPHeaderField:@"someField"];
这应该显示尝试连接数据库时生成的错误。