PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 7, 2022

[FIXED] Codeigniter base_url not working when deleting, adding and updating the data

 February 07, 2022     codeigniter, php     No comments   

Issue

I am making a codeigniter program that can Add, Edit, Delete, Update and View the data in the database. The logical error here is that the base_url is not working at all. When I click the delete, add and update button it goes to the about:blank page.

     <table cellspacing="0" cellpadding="2" border="1" width="50%">
            <tr>
                <th>S.No</th>
                <th>Name</th><th>Email</th><th>Address</th>
                <th>phone</th><th>&nbsp;</th><th>&nbsp;</th>
            </tr>

            <?php

                $i=1;
                foreach($query as $row)
                {
                ?>
                    <tr>
                        <td><?php echo $i; ?></td>
                        <td><?php echo $row->name; ?></td>
                        <td><?php echo $row->email; ?></td>
                        <td><?php echo $row->address; ?></td>
                        <td><?php echo $row->phone; ?></td>
                        <td><a href="<?php echo base_url().'/index.php/emp/update/'.$row->id; ?>">Edit</a></td>
                        <td><a href="<?php echo base_url().'/index.php/emp/delete/'.$row->id; ?>">Delete</a></td>
                    </tr>
                <?php
                    $i++;
                }
                ?>

                <tr><td colspan="7"><a href="<?php echo base_url(); ?>/index.php/emp/add_new">Add New</a></td></tr>
        </table>

Solution

If you want to used base_url. First step, You must have to URL helper loaded in your application/config/autoload.php

$autoload['helper'] = array('url');

Or you can load URL Helper Manually by

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

Then You can call base_url like

echo base_url();

But Remember One thing,

If this base_url is not set in your config.php file then CodeIgniter will get the protocol, domain and path to your installation.

But If you are define base_url in your application/config/config.php then base_url is loaded from here.



Answered By - hardik solanki
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing