CodeIgniter Forums
Issues with code - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Issues with code (/thread-73840.html)



Issues with code - Mekaboo - 06-11-2019

Hello!

I would like to use this code for profile within my code but I get errors of undefinfed variables. Here is the code:

 <div class="avatar">

                            <img alt="<?php print $this->session->userdata('user_name'); ?>" src="<?php print HTTP_IMAGES_PATH; ?>user-default.jpg">
                        </div>
                    </div>
                    <div class="card-body info">
                        <div class="title">
                            <a href="<?php print site_url() ?>profile"><?php print $userInfo['full_name']; ?></a>
                        </div>
                        <div class="desc"> <a target="_blank" href="<?php print site_url(); ?>"><?php PRINT APPLICATION_NAME; ?></a></div>        
                        <div class="desc"><?php print $userInfo['email']; ?>, <?php print $userInfo['contact_no']; ?></div>      
                        <div class="desc"><?php print $userInfo['address']; ?></div>               

I get errors about the php but dont want to delete them because I feel its important. How do I edit the php inserts so they fit my code?

Heart Heart ,
Mekaboo


RE: Issues with code - Wouter60 - 06-11-2019

What php error messages do you get, and what are the line numbers they refer to?
Without that information, it's impossible to help you.


RE: Issues with code - InsiteFX - 06-12-2019

HTTP_IMAGES_PATH
APPLICATION_NAME

Those are variables used in Compass app.

If you want to use those names then you would need to create them using DEFINE.
Then set them to the correct folders etc;


RE: Issues with code - Mekaboo - 06-12-2019

(06-11-2019, 11:56 PM)Wouter60 Wrote: What php error messages do you get, and what are the line numbers they refer to?
Without that information, it's impossible to help you.

The error I would get is "Undefined variable" and it went with this line: 

    <a href="<?php print site_url() ?>profile"><?php print $userInfo['full_name']; ?></a>

As well as lines like it. I thought of deleting the php part but O felt it would be wrong of me to do so..


RE: Issues with code - Mekaboo - 06-12-2019

(06-12-2019, 04:40 AM)InsiteFX Wrote: HTTP_IMAGES_PATH
APPLICATION_NAME

Those are variables used in Compass app.

If you want to use those names then you would need to create them using DEFINE.
Then set them to the correct folders etc;

This helps alot with one of the issues I was facing, thank so very much Heart


RE: Issues with code - jfri - 06-13-2019

(06-12-2019, 10:47 AM)Mekaboo Wrote:
(06-11-2019, 11:56 PM)Wouter60 Wrote: What php error messages do you get, and what are the line numbers they refer to?
Without that information, it's impossible to help you.

The error I would get is "Undefined variable" and it went with this line:

    <a href="<?php print site_url() ?>profile"><?php print $userInfo['full_name']; ?></a>

As well as lines like it. I thought of deleting the php part but O felt it would be wrong of me to do so..

Can you do this?
PHP Code:
<?php 
var_dump
($userInfo);
?>

Is the error also on this line? If not, what is the content of the variable? Maybe the index 'full_name' is not set. If the error is there, define the variable $userInfo


RE: Issues with code - Mekaboo - 06-13-2019

(06-13-2019, 07:20 AM)jfri Wrote:
(06-12-2019, 10:47 AM)Mekaboo Wrote:
(06-11-2019, 11:56 PM)Wouter60 Wrote: What php error messages do you get, and what are the line numbers they refer to?
Without that information, it's impossible to help you.

The error I would get is "Undefined variable" and it went with this line:

    <a href="<?php print site_url() ?>profile"><?php print $userInfo['full_name']; ?></a>

As well as lines like it. I thought of deleting the php part but O felt it would be wrong of me to do so..

Can you do this?
PHP Code:
<?php 
var_dump
($userInfo);
?>

Is the error also on this line? If not, what is the content of the variable? Maybe the index 'full_name' is not set. If the error is there, define the variable $userInfo

That's where the error is. I'm going to try your suggestion and see if it works Heart


RE: Issues with code - InsiteFX - 06-14-2019

Also show the code were your getting $userInfo from.


RE: Issues with code - Mekaboo - 06-16-2019

Thank you all so very much! After some going back and forth I took that code out and decided to try out using Bootstrap Profile cards. Simple and easier to integrate. Thanks again Heart