总是报错 !
// 确定当前页数 $p 参数$p = $_GET['p']?$_GET['p']:1;// 数据指针$offset = ($p-1)*$pagesize;$query_sql = "SELECT * FROM guestbook ORDER BY id DESC LIMIT $offset , $pagesize";$result = mysql_query($query_sql);// 如果出现错误并退出if(!$result) exit('查询数据错误:'.mysql_error());// 循环输出while($gb_array = mysql_fetch_array($result)){?><div class="guestbook-list"><p class="guestbook-head"><img src="/static/imghw/default1.png" data-src="images/<?=$gb_array['face']? alt="总是报错 !" >.gif" class="lazy" face']?>.gif" /><span class="bold"><?=$gb_array['nickname']?></span> <span class="guestbook-time">[<?=date("Y-m-d H:i", $gb_array['createtime'])?>]</span></p><p class="guestbook-content"><?=nl2br($gb_array['content'])?></p><?php // 回复 if(!empty($gb_array['replytime'])) {?><p class="guestbook-head">管理员回复: <span class="guestbook-time">[<?=date("Y-m-d H:i", $gb_array['replytime'])?>]</span></p><p class="guestbook-content"><?=nl2br($gb_array['reply'])?></p><?php } // 回复结束?></div><?php} //while循环结束?><div class="guestbook-list guestbook-page"><p><?php//计算留言页数$count_result = mysql_query("SELECT count(*) FROM guestbook");$count_array = mysql_fetch_array($count_result);$pagenum = ceil($count_array['count(*)']/$pagesize);echo '共 ',$count_array['count(*)'],' 条留言';if ($pagenum > 1) { for($i=1;$i<=$pagenum;$i++) { if($i==$p) { echo ' [',$i,']'; } else { echo ' <a href="index.php?p=',$i,'">'.$i.'</a>'; } }}?></p></div></div><!--留言列表结束-->
数据库连接
<?php/******************************数据库连接*****************************/$conn = @mysql_connect("localhost","","");if (!$conn){ die("连接数据库失败:" . mysql_error());}mysql_select_db("guestbook", $conn);//字符转换,读库mysql_query("set character set 'gbk'");//写库mysql_query("set names 'gbk'");?>
数据库建立
CREATE TABLE `guestbook` ( `id` mediumint(8) unsigned NOT NULL auto_increment, `nickname` char(16) NOT NULL, `email` varchar(60) default NULL, `face` tinyint(2) unsigned NOT NULL default '1', `content` text NOT NULL, `createtime` int(10) unsigned NOT NULL default '0', `clientip` char(15) NOT NULL, `reply` text, `replytime` int(10) unsigned default NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
但是一 测试就这句$p = $_GET['p']?$_GET['p']:1;报错 怎么办?
回复讨论(解决方案)
$_GET['p'] 是传入的变量,第一次执行就不会有,所以会报错
$p = isset($_GET['p']) ? $_GET['p'] : 1;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.
