Error 404 - The requested page does not exist

Hello,

I’m new to Yii framework and followed the tutorial to create a simple application.

Now, I have tried to create some extra pages using the gii.

I have a mysql table called tbl_articles containing 5 fields:

  • Id : varchar(20) unique primary key

  • Title : varchar(200)

  • Measurement unit : varchar(5)

  • Type : varchar(5)

  • Block : longtext

The "Block"-field should be a textfield with "unlimited" size.

Next I used the gii Model Generator to create the model "Article".

After that I used the gii Crud Generator with that model.

In the created _form.php I implement the ECLEditor for the "Block"-field.

When I load the page index.php?r=article, I see an empty list.

Next, I click "create article" and I get a form to fill in.

After I fill everything in, and submit the form, i get redirected to the page "index.php?r=article/view&id=test". Here is where I get the "Error 404 - The requested page does not exist."

In my mysql table, the row has been created.

In "article/index" and "article/admin" I can see the record.

In "article/view&id=test" and "article/update&id=test" I get the error.

When clicking on the delete button, I get a gif that shows me that something’s busy, but nothing happens.

Can anyone help me?

Grtz,

Frederik

Check your ArticleController::loadModel().

I guess it is something like this …




	public function loadModel($id)

	{

		$model = Article::model()->findByPk((int)$id);

		if ($model===null)

		{

			throw new CHttpException(404,'The requested page does not exist.');

		}

		....



But the parameter for findByPk() should be $id instead of b$id[/b] because your PK is not an integer but a varchar.

It’s a bug of Gii, and is fixed in the SVN.

P.S. Welcome to the forum.

Thanks for the answer!

What is SVN?

Svn is the revision control sistem that is used for manage the versions of Yii.

If you will download the source through svn, you can simply do update of the source for being always updated to the last revision.

Saying that is fixed in svn meands that is a problem fixed, you should update and enjoy

well i have the same problem and my function says $id instead of (int)$id .

My problem hasn’t been solved yet. Don’t know why. I did the CRUDS again. I erased the table in the DB and created it again,. I’m using Postgres and the primary key is a serial datatype. No idea