我在Windows 7操作系统上安装了Apache 2.2,Php 5.4.5和Mysql 5.5.27.我的localhost位置是G:/ local_server.我已下载CodeIgniter_2.1.3并解压缩到local_server并重命名CodeIgniter.我在CodeIgniter文件夹上创建.htaccess文件并通过以下代码:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase / CodeIgniter/
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L] …Run Code Online (Sandbox Code Playgroud) 我正在开发一个显示数据库表中数据的小应用程序.我得到2个错误,不知道为什么会有,我无法弄清楚,因为我仍然是一个菜鸟.我猜它有点蠢,请帮忙.
错误
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: querys
Severity: Warning
Message: Invalid argument supplied for foreach()
Run Code Online (Sandbox Code Playgroud)
这些错误位于我的视图页面中.
视图
<?php foreach ($queries as $row): ?>
<table>
<th>Name</th>
<th>Surname</th>
<th>phone</th>
<th>email</th>
<td><?php echo $row->name; ?></td>
<td><?php echo $row->surname; ?></td>
<td><?php echo $row->phone; ?></td>
<td><?php echo $row->email; ?></td>
</table>
<?php endforeach; ?>
Run Code Online (Sandbox Code Playgroud)
CONTROLLER
function display($offset = 0)
{
$limit = 20;
$this->load->model('info_model');
$results = $this->info_model->search($limit, $offset);
$data['queries'] = $results['rows'];
$data['num_results'] = $results['num_rows'];
$this->load->view('info_view',$data);
}
Run Code Online (Sandbox Code Playgroud)
模型
function search ($limit, …Run Code Online (Sandbox Code Playgroud) 这是一个非常愚蠢的问题,但我不知道出了什么问题.我无法通过公共方法获取私有变量的值.我正在使用CodeIgniter.
class someClass extends MY_Model {
private $table = 'sometable';
public function getTable() {
return $this->table;
}
public function updateTable($data) {
$this->db->update($this->getTable(), $data);
}
}
Run Code Online (Sandbox Code Playgroud)
当我从控制器调用此方法时,我收到以下消息:
Fatal error: Access level to someClass::$table must be public (as in class MY_Model) in /some/path/someclass.php on line 38
Run Code Online (Sandbox Code Playgroud)
我做错了什么?谢谢.
我尝试在iframe中加载codeigniter视图,
<iframe src="<?php $this->load->view('lists');?/>"></iframe>
但页面无法加载.随着我的框架工作.如何在iframe中加载此视图?
我正在寻找能够在各种环境中正确处理项目的mysql表更新的想法.我看了CI DB Forge上课,我相信这可能对我有所帮助.我的想法是:
这是正确的想法吗?这与Magento如何处理每个扩展的数据库升级非常相似.
我试图通过codeigniter来验证ajax的某些字段,但不能完全弄清楚如何"正确".
我的阿贾克斯:
var timeout = null;
$(document).ready(function(){
$('.new-user-box input').each(function(){
var key = $(this).attr('name');
$(this).on("keyup", function() {
var value = $(this).val();
if(value=="") {
return false;
}
var json = {};
json[key] = value;
json['ajax'] = '1';
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout( function() {
$.ajax({
url: 'auth/ajax_validate',
type: 'post',
data: json,
success: function(data) {
console.log(data);
}
})
}, 1000)
});
})
})
Run Code Online (Sandbox Code Playgroud)
这基本上让我的所有输入字段在keyup上发送它们的值(1秒后).
我的php(只是用户名测试的一个片段):
<?php
function ajax_validate()
{
// Test if the method is called by ajax and validate …Run Code Online (Sandbox Code Playgroud) 这是我第一次与Stripe交互并尝试将其绑定到CodeIgniter.目前,当您在我的应用程序上创建帐户时,它会将您添加到正确的条带计划中,并增加在该帐户上开帐单的总金额.
我在尝试使用此订阅计划时遇到问题#.我在他们的文档中发现,这涉及订阅计划数量.
我需要做的是当你停用一个用户时,它需要将数量更新为1.我无法弄清楚这一点.
使用他们的API,我可以通过以下方式完全删除订阅的客户:
$this->load->library( 'stripe' );
$this->stripe->customer_delete('cus_1WS0pth6srNf7H');
Run Code Online (Sandbox Code Playgroud)
现在我正在与:
$this->load->library( 'stripe' );
$customer_id = $company->stripe_id;
$this->stripe->customer_update($customer_id, **WHAT GOES HERE?**);
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.总结一下,我需要在停用用户时将我的计划数量更新为-1.用户在我的应用程序中被停用正常,但现在我需要向Stripe发送请求以将我的计划更新为少1个用户.
也许这个customer_update功能不适合用于此?Stripe.php文件中有很多内容.
一旦我解决了这个问题,我就可以将其应用于重新激活用户.
我有以下三元运算符:
<?php (strcmp($activetab,'profile') == 0 ? echo "active" : ''); ?>
Run Code Online (Sandbox Code Playgroud)
不幸的是,它没有按预期工作.我希望,如果条件是真的,那active将得到回应,否则什么都没有.
我究竟做错了什么?
我有一个带一个控制器的codeigniter应用程序(main.php)
目前,我已将htaccess文件设置为删除index.php和main.php
因此,它只是www.domain.com/function_name而不是www.domain.com/index.php/main/function_name
我的htaccess文件如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/main/$1 [L]
Run Code Online (Sandbox Code Playgroud)
ErrorDocument 404 /index.php
Run Code Online (Sandbox Code Playgroud)
我现在需要在网站上添加一大块.它目前建立在一个单独的codeigniter应用程序中,我需要移动它.该网站的新部分位于controllers/manage_emails/contacts.php ...
我的问题是,我该如何改变htaccess文件从URL中移除main.php大部分的时间,但这时如果你把它www.domain.com/manage_emails/contollername会去到正确的控制器.
谢谢!
我是Codeigniter的新手。现在,我想在视图中设置字符数限制。首先,使用$ query_result-> result()从数据库中获取数据,然后使用foreach()在视图中显示数据。
这是我的控制器,模型和视图:
public function index() {
$data = array();
$data['category'] = $this->product_model->selectAllcategory();
$data['randProduct'] = $this->product_model->selectRandomProduct();
$data['products'] = $this->product_model->selectAllProduct();
$data['maincontent'] = $this->load->view('home', $data, true);
$data['title'] = 'Welcome Russel Store';
$this->load->view('index', $data);
}
Run Code Online (Sandbox Code Playgroud)
而我的模特:
public function selectAllProduct() {
$this->db->select('*');
$this->db->from('product');
$this->db->where('status', 1);
$this->db->order_by('product_id', 'desc');
$query_result = $this->db->get();
$result = $query_result->result();
return $result;
}
Run Code Online (Sandbox Code Playgroud)
我想在视图中设置字符数限制:
http://russelstore.mastersite.info echo character_limiter($ result-> product_title,25);