Jump to content

[CI] preg_match() error


Tripic

Recommended Posts

ok first things first heres the var dump from my controller

 

array(2) { ["title"]=> string(13) "My Blog Title" [0]=> array(4) { ["title"]=> string(4) "Test" ["body"]=> string(5) "Test1" ["date"]=> string(19) "0000-00-00 00:00:00" ["author"]=> string(1) "1" } }

 

heres the error i get when i try to go through the view file

 

A PHP Error was encountered

Severity: Warning

 

Message: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 2

 

Filename: libraries/Parser.php

 

Line Number: 161

 

the code for the cotroller

 

<?php

 

class Blog extends Controller {

function Blog(){

parent::Controller();

//$this->load->scaffolding('blog_entries');

}

function index(){

$this->load->helper('html');

$this->load->library('parser');

$this->load->library('ion_auth');

$data ['title'] = "My Blog Title";

        $dbdata ['query'] = $this->db->get('blog_entries');

        foreach($dbdata['query']->result() as $row) { $data[] = array('title' => $row->title, 'body' => $row->body, 'date' => $row->date, 'author' => $row->author); }

      // var_dump($data);

      $this->parser->parse('blog_view', $data);

 

}

}

 

?>

 

the code for the view file

 

<head>

<?

echo link_tag('awesomewinds.css');

$this->load->helper('url');

?>

<? echo $title ?>

 

 

 

</head>

<body>

<table width="940" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#DDE9F7">

<tr>

<td>

<table width="940" border="0" cellspacing="0" cellpadding="0">

<tr>

<td colspan="8" width="940"><div class="header"></div></td>

</tr>

<tr>

<td width="237"><div class="frametopleft"></div></td>

<td width="100"><div class="menubookstore"><a href="#"></a></div></td>

<td width="99"><div class="menuart"><a href="#"></a></div></td>

<td width="74"><div class="menublog"><a href="#"></a></div></td>

<td width="91"><div class="menulinks"><a href="#"></a></div></td>

<td width="108"><div class="menucontactus"><a href="#"></a></div></td>

<td width="109"><div class="menufun"><a href="#"></a></div></td>

<td width="124"><div class="frametopright"></div></td>

</tr>

<tr>

<td colspan="8">

<table width="940" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="30"><div class="backgroundleft"></div></td>

<td width="168">

<table width="168" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="168"><div class="leftmenu1"></div></td>

</tr>

<tr>

<td width="168"><div class="leftmenu2"><a href="#"></a></div></td>

</tr>

<tr>

<td width="168"><div class="leftmenu3"><a href="#"></a></div></td>

</tr>

<tr>

<td width="168"><div class="leftmenu4"><a href="#"></a></div></td>

</tr>

<tr>

<td width="168"><div class="leftmenu5"><a href="#"></a></div></td>

</tr>

<tr>

<td width="168"><div class="leftmenu6"></div></td>

</tr>

</table>

</td>

<td width="577"><div class="backgroundmiddle"><br><br>

 

 

 

 

</div></td>

<td width="139">

<table width="139" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="139"><div class="rightmenu1"></div></td>

</tr>

<tr>

<td width="139"><div class="rightmenu2"><a href="http://www.awesome-winds.com/proto/index.php/auth/login"></a></div></td>

</tr>

<tr>

<td width="139"><div class="rightmenu3"><a href="http://www.awesome-winds.com/proto/index.php/auth/create_user"></a></div></td>

</tr>

<tr>

<td width="139"><div class="rightmenu4"><a href="#"></a></div></td>

</tr>

<tr>

<td width="139"><div class="rightmenu5"></div></td>

</tr>

<tr>

<td>

<table width="139" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="31"><div class="rightmenu6"></div></td>

<td width="86"><img src="http://www.awesome-winds.com/random.php" width="85" height="84" border="0">  </td>

<td width="22"><div class="rightmenu7"></div></td>

</tr>

</table>

</td>

</tr>

<tr>

<td width="139"><div class="rightmenu8"></div></td>

</tr>

</table>

</td>

<td width="26"><div class="backgroundright"></div></td>

</tr>

</table>

</td>

</tr>

</table>

       

</td>

</tr>

 

</table>

</body>

Link to comment
Share on other sites

I'm guessing you're using the codeigniter php framework. Your controller/view look fine. You'll want to get support from the codeigniter community on this as there appears to be something wrong with the parser library you're using.

 

NOTE: Whenever you post code can you wrap it within code (


or


) tags.

Link to comment
Share on other sites

There's nothing wrong with the template parser class. If you were to carefully read the docs, http://codeigniter.com/user_guide/libraries/parser.html , then you would see your mistakes. While you DO have mistakes in your controller and view code that would prevent it from working as a normal controller/view relationship, your code is more suited to normal controller/view usage than that of the template parser class. For instance, in your view, you are trying to use $title, but template parser class usage would require {title}. Also, in your controller, you are building up a $data array, but your foreach statement would create an array with numeric indices. I don't believe there is any way for you to access the data like that. There's really no reason to use the template parser class if you are the dev and designer.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.