我已经将我的codeigniter版本从2.2.4一步一步更新到3.0.6,我收到一个错误:
An uncaught Exception was encountered
Type: Error
Message: Call to undefined function mysql_pconnect()
Filename: path-to-project\system\database\drivers\mysql\mysql_driver.php
Line Number: 135
Backtrace:
File: path-to-project\application\controllers\Main.php
Line: 10
Function: __construct
File: path-to-project\index.php
Line: 315
Function: require_once
Run Code Online (Sandbox Code Playgroud)
我刚刚将index.php文件和系统目录替换为新目录,并根据教程对我的应用程序进行了一些更改.
这是主控制器:
class Main extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('main_model');
}
}
Run Code Online (Sandbox Code Playgroud)
是什么导致了这个问题?!
而这是链接的教程.
我一直处理一个问题.如何在函数中使用重定向设置验证错误?这是我控制器中的代码:
function send()
{
$this->form_validation->set_rules('e-mail', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('cellphone', 'Cellphone Number', 'trim|required|is_natural');
$this->form_validation->set_message('required', '%s is required.');
$this->form_validation->set_message('valid_email', '%s is not a valid Email Address');
$this->form_validation->set_message('is_natural', '%s can only contain numbers.');
$this->form_validation->set_error_delimiters('<li>', '</li>');
if($this->form_validation->run() == FALSE)
{
redirect ('/');
}
else
{
echo '<pre>';
print_r($_POST);
echo '<pre>';
}
}
Run Code Online (Sandbox Code Playgroud)
这是我在视图文件中使用的代码:
<? if (validation_errors())
{
echo '<div id="validation_errors" title="Error:">';
echo '<div class="response-msgs errors ui-corner-all"><span>Errors:</span><br /><ul>';
echo validation_errors();
echo '</ul></div>';
echo '</div>';
}
?>
Run Code Online (Sandbox Code Playgroud) foreach($categories as $category)
{
print_r($category);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码给出了以下结果.
stdClass Object
(
[category_Id] => 4
[category_Title] => cat 4
)
stdClass Object
(
[category_Id] => 7
[category_Title] => cat 7
)
stdClass Object
(
[category_Id] => 6
[category_Title] => cat 6
)
Run Code Online (Sandbox Code Playgroud)
我该如何使用implode(', ' )以获得以下结果:
猫4,猫7,猫6
我用它,但是我收到了一个错误
我想缩放 SVG 组元素,以便它缩放并转换为路径所在的点。这意味着,当我单击路径时,必须以路径适合视口的高度或宽度的方式缩放组并将其居中于路径。我真的尝试了很多方法,比如使用getBBox()获取路径的高度、宽度、x 和 y 并从视口偏移中减去它们。我还尝试了 d3.js 来操作它。但是,我找不到好的方法。
这是包含 SVG 的 HTML:
<div style="width: 700px; height:600px; border:1px solid #d0d0d0; background: #e8e8e8; margin: 0 auto;">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 255.1 170.1" style="enable-background:new 0 0 255.1 170.1;" xml:space="preserve" width="100%" height="100%">
<g id="floorplan">
<path fill="#ED1C24" d="M35.8,51.8h36.3c1.6,0,2.8-1.3,2.8-2.8V22.1c0-1.6-1.3-2.8-2.8-2.8H35.8c-1.6,0-2.8,1.3-2.8,2.8v26.8
C33,50.5,34.3,51.8,35.8,51.8z"/>
<path fill="#4A68B1" d="M209.8,114.3h36.3c1.6,0,2.8-1.3,2.8-2.8V84.6c0-1.6-1.3-2.8-2.8-2.8h-36.3c-1.6,0-2.8,1.3-2.8,2.8v26.8
C207,113,208.3,114.3,209.8,114.3z"/>
<path fill="#F8991D" d="M134.3,158.8h36.3c1.6,0,2.8-1.3,2.8-2.8v-26.8c0-1.6-1.3-2.8-2.8-2.8h-36.3c-1.6,0-2.8,1.3-2.8,2.8v26.8
C131.5,157.5,132.8,158.8,134.3,158.8z"/>
<path fill="#ed2590" d="M13.1,124.3h36.3c1.6,0,2.8-1.3,2.8-2.8V94.6c0-1.6-1.3-2.8-2.8-2.8H13.1c-1.6,0-2.8,1.3-2.8,2.8v26.8
C10.2,123,11.5,124.3,13.1,124.3z"/>
<path fill="#356732" d="M161.1,42.5h36.3c1.6,0,2.8-1.3,2.8-2.8V12.8c0-1.6-1.3-2.8-2.8-2.8h-36.3c-1.6,0-2.8,1.3-2.8,2.8v26.8
C158.2,41.2,159.5,42.5,161.1,42.5z"/>
</g>
</svg>
</div>
Run Code Online (Sandbox Code Playgroud)
在一段时间里,我一直在处理分页课中的问题.
问题在于,除了第1页的链接外,所有分页都可以.
所有链接都像:
example.com/method/page/2
example.com/method/page/3
Run Code Online (Sandbox Code Playgroud)
...
但是,当我想转到第1页时,链接看起来像:
example.com/method/page/
Run Code Online (Sandbox Code Playgroud)
当然,它看起来有些尴尬.我希望它看起来像:
example.com/method/page/1
Run Code Online (Sandbox Code Playgroud)
如何在分页库中修复此问题?!
我想立即在页面中插入类似的字符串到数据库!例如,我想将每一行插入表格行:
$flag = 'AD.png'; $title = 'Andorra';
$flag = 'AE.png'; $title = 'United Arab Emirates';
$flag = 'AF.png'; $title = 'Afghanistan';
$flag = 'AG.png'; $title = 'Antigua and Barbuda';
$flag = 'AI.png'; $title = 'Anguilla';
$flag = 'AL.png'; $title = 'Albania';
$flag = 'AM.png'; $title = 'Armenia';
$flag = 'AN.png'; $title = 'Netherlands Antilles';
Run Code Online (Sandbox Code Playgroud)
我的数据库行是:
`flag_Id` int(11) NOT NULL AUTO_INCREMENT,
`flag_Title` varchar(250) NOT NULL,
`flag_ImageId` varchar(250) NOT NULL,
PRIMARY KEY (`flag_Id`)
Run Code Online (Sandbox Code Playgroud)
我该怎么办?!
我创建了一个用于访问点击的帮助程序,它包含一个将一些数据插入数据库的函数:
hit_counter_helper.php:
function count_hits($options = array())
{
//Determine whether the user agent browsing your site is a web browser, a mobile device, or a robot.
if ($this->agent->is_browser())
{
$agent = $this->agent->browser() . ' ' . $this->agent->version() . ' - ' . $this->agent->platform();
}
elseif ($this->agent->is_robot())
{
$agent = $this->agent->robot();
}
elseif ($this->agent->is_mobile())
{
$agent = $this->agent->mobile();
}
else
{
$agent = 'Unidentified User Agent';
}
//Detect if the user is referred from another page
if ($this->agent->is_referral())
{
$referrer = …Run Code Online (Sandbox Code Playgroud) codeigniter ×4
php ×3
d3.js ×1
database ×1
helper ×1
html ×1
implode ×1
javascript ×1
jquery ×1
mysql ×1
pagination ×1
string ×1
svg ×1
url ×1
validation ×1