Fatal error: Call to undefined function session_register() 的解决方法

版权声明:https://github.com/wusuopubupt https://blog.csdn.net/wusuopuBUPT/article/details/8698981
1、PHP4.2以上版本不需要用session_register()注册SESSION变量,直接用: 
$_SESSION["string"]=“string"; 
赋值。 
2、用$_SESSION["string"]获取变量值。 
3、用$_SESSION["string"][$n]可传递SESSION数组。
阅读更多

【LAMP】Fatal error: Call to undefined function mb_detect_encoding()

06-15

我安装LAMP环境,php-xxx-.tar.gz解压缩后的目录 /home/default7/LAMP/php-5.5.13rnPHP安装到的目录 /usr/local/php5rn然后我安装之后,打开phpmyadmin,报错提示:rnrn[code=html]rnFatal error: Call to undefined function mb_detect_encoding() in /usr/local/apache2/htdocs/phpmyadmin/libraries/php-gettext/gettext.inc on line 177rn[/code]rnrn命令提示行查看php已经安装的模块:[b][color=#FF0000]mbstring是存在的[/color][/b]。rn[quote]rn[root@localhost php-5.5.13]# php -mrn[PHP Modules]rnbz2rncalendarrnCorernctyperncurlrndaterneregrnexifrnfileinfornfilterrnftprngettextrngmprnhashrniconvrnjsonrnlibxmlrnmbstringrnopensslrnpcntlrnpcrernPharrnreadlinernReflectionrnsessionrnshmoprnSimpleXMLrnsocketsrnSPLrnstandardrntokenizerrnxmlrnziprnzlibrnrn[Zend Modules]rnrn[/quote]rnrn[b]查看phpinfo,相关几个:[/b]rn[code=csharp]rnPHP Version 5.5.13rnConfigure Command rn './configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql' '--prefix=/usr/local/php5' rnrnServer APIrn Apache 2.0 HandlerrnrnVirtual Directory Supportrn enabledrnrnConfiguration File (php.ini) Pathrn /usr/local/php5/librnrnLoaded Configuration Filern /usr/local/php5/lib/php.inirnrnScan this dir for additional .ini files (none)rnAdditional .ini files parsed (none) rnextension_dirrn /usr/local/php5/lib/php/extensions/no-debug-zts-20121212rn /usr/local/php5/lib/php/extensions/no-debug-zts-20121212rnrn[/code]rnrn查看php5安装后的extension目录(是空的):rn[code=csharp]rn[root@localhost ext]# ll /usr/local/php5/lib/php/extensions/no-debug-zts-20121212rntotal 488rn-rwxr-xr-x. 1 root root 495775 Jun 15 01:01 opcache.sorn[root@localhost ext]# ll /usr/local/php5/lib/php/extensionsrntotal 4rndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 no-debug-zts-20121212rn[/code]rnrn但是在安装后的目录里面另外一个目录却有(目录 /usr/local/php5/include/php/ext):rn[code=c]rn[root@localhost ext]# pwdrn/usr/local/php5/include/php/extrn[root@localhost ext]# llrntotal 68rndrwxr-xr-x. 3 root root 4096 Jun 15 01:01 daterndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 domrndrwxr-xr-x. 3 root root 4096 Jun 15 01:01 eregrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 filterrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 hashrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 iconvrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 jsonrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 libxmlrndrwxr-xr-x. 2 root root 4096 Jun 15 01:02 mysqlndrndrwxr-xr-x. 3 root root 4096 Jun 15 01:01 pcrerndrwxr-xr-x. 2 root root 4096 Jun 15 01:02 pdorndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 pharrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 sessionrndrwxr-xr-x. 2 root root 4096 Jun 15 01:01 splrndrwxr-xr-x. 3 root root 4096 Jun 15 01:01 sqlite3rndrwxr-xr-x. 2 root root 4096 Jun 15 01:02 standardrndrwxr-xr-x. 2 root root 4096 Jun 15 01:02 xmlrn[root@localhost ext]# rnrn[/code]rnrnrn在安装文件夹(/home/default7/LAMP/php-5.5.13/ext)中有mbstring:rn[code=csharp]rn[root@localhost ext]# llrntotal 328rndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 bcmathrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 bz2rndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 calendarrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 com_dotnetrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:27 ctyperndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 curlrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:25 daterndrwxr-xr-x. 6 1001 1001 4096 May 28 17:06 dbarndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:27 domrndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 enchantrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:25 eregrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 exifrn-rwxr-xr-x. 1 1001 1001 8174 May 28 17:06 ext_skelrn-rw-r--r--. 1 1001 1001 1524 May 28 17:06 ext_skel_win32.phprndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:27 fileinforndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:28 filterrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 ftprndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 gdrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 gettextrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 gmprndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:43 hashrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:28 iconvrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 imaprndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 interbaserndrwxr-xr-x. 20 1001 1001 4096 May 28 17:06 intlrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:28 jsonrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 ldaprndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:26 libxmlrndrwxr-xr-x. 6 1001 1001 4096 May 28 17:06 mbstringrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 mcryptrndrwxr-xr-x. 2 1001 1001 4096 May 28 17:06 mssqlrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:28 mysqlrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 mysqlirndrwxr-xr-x. 3 1001 1001 4096 Jun 15 00:32 mysqlndrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 oci8rndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 odbcrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:35 opcacherndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 opensslrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pcntlrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:26 pcrerndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:28 pdorndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_dblibrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_firebirdrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_mysqlrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_ocirndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_odbcrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pdo_pgsqlrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:29 pdo_sqliterndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pgsqlrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 01:41 pharrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:29 posixrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 pspellrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 readlinerndrwxr-xr-x. 2 1001 1001 4096 May 28 17:06 recoderndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:29 reflectionrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:29 sessionrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 shmoprndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:29 simplexmlrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 skeletonrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 snmprndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 soaprndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 socketsrndrwxr-xr-x. 6 1001 1001 4096 Jun 15 00:29 splrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:26 sqlite3rndrwxr-xr-x. 5 1001 1001 12288 Jun 15 01:41 standardrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 sybase_ctrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 sysvmsgrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 sysvsemrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 sysvshmrndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 tidyrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:31 tokenizerrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 wddxrndrwxr-xr-x. 4 1001 1001 4096 Jun 15 00:31 xmlrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:31 xmlreaderrndrwxr-xr-x. 4 1001 1001 4096 May 28 17:06 xmlrpcrndrwxr-xr-x. 5 1001 1001 4096 Jun 15 00:31 xmlwriterrndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 xslrndrwxr-xr-x. 5 1001 1001 4096 May 28 17:06 ziprndrwxr-xr-x. 3 1001 1001 4096 May 28 17:06 zlibrnrn[/code]rnrn在php.ini中有关extension_dir的都是注释掉了的,但是查看phpinfo却有mysql pdo 这些全都显示。rnrnrn

Fatal error: Call to undefined function mysql_connect()

08-09

真背! 刚才写了一大堆 切换个输入法 sogou浏览器页面崩溃了 全部没有了rn我的环境是 php 5.3.1 +apache 2.2.14+mysql 5.1rn从网上搞了个留言板整合 虽然汇报一些错 不过数据总算能存到数据库中了,可是查看留言板却不行rn没有数据 然后我把 那个页面放到 php designer中debug 就报这样的错:rnFatal error: Call to undefined function mysql_connect() rn我承认 刚开始环境配置好的时候 通过 phpinfo() 测试 没有mysql 出现 别以为我傻rn那些去掉extension前面的;号 我都做了 没用 然后把pdo_mysql.default_socket,rnmysql.default_port,mysqli.default_port 还有一些默认的都改成我自己的数据库用户名 密码rn重启Apache 终于好了! 看到mysql mysqli了rn可是查看留言依然没有..。rn我得罪谁了 这么背 碰到那些无语的问题...rn我把 那个代码贴出来 各位大侠给我看看谢谢了~rncongfig.phprn[code=PHP]rnrn[/code]rn----------------------------------------------------------rnconn.phprn[code=PHP]rn 0xa0) rn $tmpstr .= substr($str, $i, 2);rn $i++;rn elsern $tmpstr .= substr($str, $i, 1);rn rn return $tmpstr;rn rnrnfunction htmlgl($str)rnrn$str = preg_replace( "@@is", "", $str ); rn$str = preg_replace( "@@is", "", $str ); rn$str = preg_replace( "@@is", "", $str ); rn$str = preg_replace( "@<(.*?)>@is", "", $str ); rnreturn $str;rnrnrnfunction safegl($str)rnrn$str=trim($str);rn$str=str_replace(",","",$str);rn$str=str_replace("'","",$str);rn$str=str_replace("%","",$str);rn$str=str_replace("<","",$str);rn$str=str_replace("?","",$str);rnreturn $str;rnrndefine("version","V2010.1");rn?>rn[/code]rn然后就在 Index.php debug 报错了rn[code=PHP]rnrn 查看留言rn rn rn rn rn rn rn 首页 | 上一页 |';rnrnrnif($page==$pagecount||$pagecount==0)rnrn$fypage.=' 下一页 | 尾页 ';rnrnelsernrn$fypage.=' 下一页 | 尾页 ';rnrnrnrn$fypage.='转到:';rn$a=1;rnwhile($a<=$pagecount)rnrn if($a==$page) rn rn $fypage.="第".$a."页"; rn rn elsern rn $fypage.="第".$a."页"; rn rn $a=$a+1;rnrn$fypage.="";rnecho $fypage;rnrnrnrnif($lysh==1)rn rn$sql='select * from guestbook where sh=1 order by id desc limit '.($page-1)*$pagesize.','.$pagesize;rn rn elsern rn$sql='select * from guestbook order by id desc limit '.($page-1)*$pagesize.','.$pagesize;rn rnrn$result=mysql_query($sql);rn$i=0;rnwhile($rs=mysql_fetch_array($result,MYSQL_ASSOC))rnrn$i=$i+1;rn?>rn rn NO. 留言人: rn rn 联系QQ: Email: 留言时间: rn rn 主题:rn rn rn 管理员回复:rn rn rn rn rn rn rn rn rn rn rn rn rn[/code]rn真的崩溃了...

错误提示:Fatal error: Call to undefined function mysqli_num_row()

04-05

错误提示就如标题所示,网上也找了一圈,差不多都是说没有开启php_mysqli模块,我的wampserver环境本身已经开启,但是我还是去重新关闭在开启,结果都是一样,有一点很奇怪,网上一般都是在链接数据库的时候失败,但是我链接数据库没有提示失败,而是在使用mysqli_num_row时候出现错误rnrn下面先上下我在查看phpinfo下mysqli下的开启情况rn mysqlirnMysqlI Support enabledrnClient API library version mysqlnd 5.0.8-dev - 20102224 - $Id: 65fe78e70ce53d27a6cd578597722950e490b0d0 $rnActive Persistent Links 0rnInactive Persistent Links 0rnActive Links 0rnrnDirective Local Value Master Valuernmysqli.allow_local_infile On Onrnmysqli.allow_persistent On Onrnmysqli.default_host no value no valuernmysqli.default_port 3306 3306rnmysqli.default_pw no value no valuernmysqli.default_socket no value no valuernmysqli.default_user no value no valuernmysqli.max_links Unlimited Unlimitedrnmysqli.max_persistent Unlimited Unlimitedrnmysqli.reconnect Off Offrnrnrn下面是我的代码部分rn[code=php]MySQL Error: " . mysqli_error($conn));rn if (mysqli_num_row($r) == 0) // 如果查询验证电子邮件地址未被使用,则注册用户rn $a = md5(uniqid(rand(), true)); // 创建一个激活码(创建一个长度正好为32个字符的字符串)rn $q = "INSERT INTO users (username, email, password, active, registration_date) VALUES ('$un', '$e', SHA1('$p'), '$a', NOW() )";rn $r = mysqli_query ($conn, $q) or trigger_error("Query: $q\n MySQL Error: " . mysqli_error($conn)); rn if (mysqli_affected_rows($conn) == 1) rn $body = "感谢您的注册,激活您的帐户,请点击这里:\n\n";rn $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a";rn mail($trimmed['email'], '确认注册', $body, 'From: 414412984@qq.com');rn echo ' 感谢您的注册!一封确认邮件已经发送到您的邮箱。请在该电子邮件中单击链接,以激活您的帐户。';rn exit();rn else rn echo ' 用户注册失败,为此我们表示抱歉,请在注册一次';rn rn else // 查询验证出来的电子邮件地址已经被注册rn echo ' 电子邮件地址已经被注册';rn rn else rn foreach ($errors as $msg) // Print each error.rn echo " - $msg \n";rn rn rn mysqli_close($conn);rnrn?>rnrn rn 主页 > 注册rn rn rn rn 用户名:rn 限5~20个字符,可用中文、英文、数字及“_”、“-”组成rn rn rn 电子邮件:rn 请填写您的常用邮箱,它是您激活帐号和找回密码的凭证!rn rn rn 登录密码:rn 密码由4-20位字母、数字组成rn rn rn 确认密码:rn 请再次输入密码rn rn rn 验证码:rn rn 看不清,请重新点击验证码(注意大小写)rn rn rn rn rn rn rn rn[/code]

没有更多推荐了,返回首页