Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL查询中的strotime[基本PHP页面]_Php_Mysql - Fatal编程技术网

MySQL查询中的strotime[基本PHP页面]

MySQL查询中的strotime[基本PHP页面],php,mysql,Php,Mysql,我在不使用模板引擎的情况下给自己上了一门基本的PHP进修课程(尽管我最近学了一些Smarty和Twig,我觉得我应该继续练习基本PHP),这是我的基本页面,显示了车辆列表以及车辆注册时间: <?php // Connects to your Database mysql_connect("localhost", "testing", "testingpass") or die(mysql_error()); mysql_select_db("cars1") or die(my

我在不使用模板引擎的情况下给自己上了一门基本的PHP进修课程(尽管我最近学了一些Smarty和Twig,我觉得我应该继续练习基本PHP),这是我的基本页面,显示了车辆列表以及车辆注册时间:

 <?php 
 // Connects to your Database 
 mysql_connect("localhost", "testing", "testingpass") or die(mysql_error()); 
 mysql_select_db("cars1") or die(mysql_error()); 
 $data = mysql_query("SELECT * FROM autos") 
 or die(mysql_error()); 
 echo "<table border cellpadding=3>"; 
 while($info = mysql_fetch_array( $data )) 
 { 
 "<tr>"; 
 //echo "<td>"date("d M Y",strtotime($info['registered']));"</td> "; 
 echo "<td><tr>".$info['make'] ." ".$info['model'] ."</td><tr> "; 
 } 
 echo "</table>"; 
 ?> 

如果datetime被注释掉,它就可以工作,但是如果它没有注释,页面就会显示为空白——我正在使用MAMP作为我的Web服务器,最新的PHP

对于一个简单的页面,这很好,但我应该如何格式化这个日期? (我使用了上的教程来尝试这一点)

我应该做些什么更改来解决日期和时间的问题,否则它可以作为一个基本的MySQL php查询正常工作。

应该是这样的

echo "<td>".date("d M Y",strtotime($info['registered']))."</td> ";
echo”“。日期(“日期”,标准时间($info['registered']);

对于concantate字符串,您必须使用

首先,屏幕为空的原因是大多数默认PHP安装都关闭了错误报告。您需要编辑php.ini文件来修复此问题。打开并搜索
display\u errors
,然后对其进行更改

第二,您缺少的第一个错误是前面没有回声的

第二个您很可能没有看到的错误是缺少连接运算符

echo "<td>"date("d M Y",strtotime($info['registered']));"</td> "
echo“日期(年月日),标准时间($info['registered']);" "
应该是

echo "<td>" . date("d M Y",strtotime($info['registered'])) . "</td> "
echo”“。日期(“年月日”,标准时间($info['registered'])。" "

错误报告(E\u ALL)
添加到顶部。默认情况下,您的错误处于关闭状态。了解如何使用
echo
,阅读文档进行var_转储($info]);您将看到错误点:echo.date(“dmy”,strottime($info['registered']);他还有
如果没有
echo
,您可能想指出,这里也不能使用
错误报告()
,因为他需要启用
显示错误。另外,您不能在运行时设置它,因为这是一个解析错误