[英]Notice: Undefined index: pre in C:\wamp\www\blog\news.php on line 164
I am making a blog for myself in Dreamweaver and well I have run into some trouble, I want to display text from a database and yet it won't work for some reason. 我在Dreamweaver中为自己创建了一个博客,但是遇到一些麻烦,我想显示数据库中的文本,但是由于某些原因它无法正常工作。 I keep getting this error:
我不断收到此错误:
Notice: Undefined index: pre in C:\\wamp\\www\\blog\\news.php on line 164 This is the block of code where the error is:
注意:未定义的索引:第164行的C:\\ wamp \\ www \\ blog \\ news.php中的pre这是代码块,其中的错误是:
<div id="blog_posts">
<?php do { ?>
<h2><?php echo $row_getDisplay['title']; ?></h2>
<p class="updated"><?php echo $row_getDisplay['formatted']; ?></p>
<p><?php echo $row_getDisplay['pre']; ?></p>
<?php } while ($row_getDisplay = mysql_fetch_assoc($getDisplay)); ?>
Can anyone please help? 谁能帮忙吗? I have been trying for days!
我已经尝试了好几天了!
使用while(...) { }
循环而不是do { } while(...)
循环,这样$row_getDisplay
会在第一次迭代时初始化。
In your array there are not index 'pre'... 在您的数组中没有索引'pre'...
You can use 您可以使用
echo isset($row_getDisplay['pre'])?$row_getDisplay['pre']:'';
for using your code with incorrect index. 使用错误索引的代码。
PHP indicating the problem is that there index "pre". PHP指出问题在于索引“ pre”。 Try to make an inspection of the variable $ row_getDisplay using var_dump() (http://www.php.net/manual/en/function.var-dump.php).
尝试使用var_dump()(http://www.php.net/manual/en/function.var-dump.php)检查变量$ row_getDisplay。 With this function you can check if the "pre" exists in the array of fields.
使用此功能,您可以检查字段数组中是否存在“ pre”。
<div id="blog_posts">
<?php do { ?>
<?php var_dump($row_getDisplay); ?>
<h2><?php echo $row_getDisplay['title']; ?></h2>
<p class="updated"><?php echo $row_getDisplay['formatted']; ?></p>
<p><?php echo $row_getDisplay['pre']; ?></p>
<?php } while ($row_getDisplay = mysql_fetch_assoc($getDisplay)); ?>
Regards!. 问候!。
只需检查数组的内容,然后回显"<pre>",print_r($row_getDisplay, TRUE),"</pre>"
以便可以查看其内容,里面可能没有pre
index pre
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.