2012-05-20 81 views
1

我的数据没有从数据库中取出。我不知道为什么。PHP中发生致命错误:超过30秒的最大执行时间

mysql_connect("localhost","root",""); 
mysql_select_db("managment"); 

$q=mysql_query("select name,father_name,dob,qualification,identity_type,identity_no,gender,email,address1,city,state,country,phone_no,mobile_no,emergency_no,relation,address from employee"); 

echo <table border='1'> 
    <tr> 
     <th>NAME</th> 
     <th>Fathet Name</th> 
     <th>Dob</th> 
     <th>Qualification</th> 
     <th>Identity Type</th> 
     <th>Identity No</th> 
     <th>Gender</th> 
     <th>Email</th> 
     <th>address</th> 
     <th>City</th> 
     <th>State</th> 
     <th>COUNTRY</th> 
     <th>Phone</th> 
     <th>Mobile</th> 
     <th>Emergency No</th> 
     <th>Relation</th> 
     <th>Address</th>"; 

while($row=mysql_fetch_array($q)); 
{ 
    echo "<tr> 
      <td>$row[name]</td> 
      <td>$row[father_name]</td> 
      <td>$row[dob]</td> 
      <td>$row[qualification]</td> 
      <td>$row[identity_type]</td> 
      <td>$row[identity_no]</td> 
      <td>$row[gender]</td> 
      <td>$row[email]</td> 
      <td>$row[address1]</td> 
      <td>$row[city]</td> 
      <td>$row[state]</td> 
      <td>$row[country]</td> 
      <td>$row[phone_no]</td> 
      <td>$row[mobile_no]</td> 
      <td>$row[emergency_no]</td> 
      <td>$row[relation]</td> 
      <td>$row[address]</td> 
      </tr><br>"; 
} 

echo "</table>"; 
+3

在while()后立即删除';'。并且请停止使用古老的mysql_ *函数编写新的代码。他们不再保持和社区已经开始了[弃用过程(http://news.php.net/php.internals/53799)。相反,您应该了解准备好的语句并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/mysqli)。如果你关心学习,[这里是一个很好的PDO相关教程](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers)。 – DCoder

+0

使用“SELECT *”。这很容易,它不会减慢你的服务器,直到你会注意到 –

+0

,有时它会更快...... –

回答

2

替换此:

echo 
<table border='1'> 

有了这个:

echo " 
<table border='1'> 

而且替换此:

while($row=mysql_fetch_array($q)); 

有了这个:

while($row=mysql_fetch_array($q)) 

此外,开始使用PDO或像DCoder这样的mysqli_ *函数()已经提出。 mysql_ *函数现在已被弃用。

+0

'我插入数据库的日期和手机号码,但没有正确插入。 作为日期插入12-04-1988,但数据库显示只有12和插入手机号码8882989855,但数据库显示2147483647 ..我不知道最新的问题...什么格式设置在我的SQL数据库....请帮助我。 date int(20) mobile int(20)' – user1406284

+0

在将日期插入数据库之前,使用strtotime()函数:http://php.net/manual/en/function.strtotime.php – Jeroen

0

应设置用户和密码(假设你有一个) ,如果错误的encoutring是一个你所提到的, 试试这行代码查询之前:

void set_time_limit (int $seconds) 

一般情况下,和Jeroen的回答可能会解决你的问题。

+1

和/或者在查询中使用'limit'。 – John

+0

'我在数据库中插入日期和手机号码,但未正确插入。 作为日期插入12-04-1988,但数据库显示只有12和插入手机号码8882989855,但数据库显示2147483647 ..我不知道最新的问题...什么格式设置在我的SQL数据库....请帮助我。(20) date int(20) mobile int(20)' – user1406284

+0

设定日期为日期,有日期选项。 –

0

你可以最大限度的延长执行时间是这样的:

ini_set('max_execution_time', 600); //600 seconds = 10 minutes 
0

您还需要包装在{变量}和引用键

“$行[名]”应为“{ $ row ['name']}“

echo "<tr> 
     <td>{$row['name']}</td> 
     <td>{$row['father_name']}</td> 
     <td>{$row['dob']}</td> 
     <td>{$row['qualification']}</td> 
     <td>{$row['identity_type']}</td> 
     <td>{$row['identity_no']}</td> 
     <td>{$row['gender']}</td> 
     <td>{$row['email']}</td> 
     <td>{$row['address1']}</td> 
     <td>{$row['city']}</td> 
     <td>{$row['state']}</td> 
     <td>{$row['country']}</td> 
     <td>{$row['phone_no']}</td> 
     <td>{$row['mobile_no']}</td> 
     <td>{$row['emergency_no']}</td> 
     <td>{$row['relation']}</td> 
     <td>{$row['address']}</td> 
     </tr><br>"; 
相关问题