Undefined variable in a template file [closed] - php

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am new here, so please bear with me.
Am trying to run a project built using the codeigniter.
The project is an online registration system,but am getting the undefined variable error in some parts of my page.
Please if you got the time to go over the project and help me out I will be very grateful.
Here is the link to the whole system.
NB:It contains the exported database already( the database is called 'orsdb' )
Cheers!!!
https://drive.google.com/open?id=0ByYO-aax6KH3cnJNRnBsNEgwd1k

You should check every variable in your CI view part before printing it, you can use isset() to check you variable is either define or not. Example -
<?php echo isset($var) ? $var:""; ?>
You can also use empty() function to check variables.
Another thing is if your variable is always undefined then you must check your array which contains data fetching from database in CI controller and print the array to check your all required value does exist or not. If not exists then check your SQL query whether it fetches your required data or not.

Related

I need help on figuring out how to get the isset() function to work [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 months ago.
Improve this question
Create a new PHP file called lab2.php.
Inside, add the HTML skeleton code and give its title “Lab Week 2”.
Create a form asking for the person’s name and favourite ice cream flavour.
Store the data using variables.
Use the isset function to check.
Print the results.
PHP CODE
HTML CODE
You should use POST request for sending data from user(.html file) to server(.php file).
In your HTML file, comment this
//<form action="lab2.php" method="get">
and use this
<form action="lab2.php" method="post">
In yout PHP file, you can get data using
if(isset($_POST['icecream'])) {
echo $_POST['icecream']
}

Insert data to database using foreach loop php [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Ex: If I have code :
$data = array('a','b','c');
foreach($data as $val){
mysql_query("INSERT INTO db (`title`)VALUES('$val')");
}
I want to insert all data from variable $val how can I coding it ?
please help !!!
thank !!
There are two things wrong which i can see at a glance.
mysql is deprecated, use mysqli instead. Reference
Since you will have to switch over to mysqli you will need to reference your database connection every time you want to do a mysql database related operation, unless you do some PHP magic (classes or methods).
Other than these two i guess there is no problem in your code, the for loop should work perfectly fine.

What would cause a defined variable to throw an undefined notice? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
In opencart, I have a variable sales_representative in a foreach loop. It gets defined and put into an array, then gets out-put in a .tpl file. Everything works as it should. But I get a notice up top saying undefined index: sales_representative... If it was undefined I wouldn't be getting a result displayed... Any thoughts?
Make sure before you give it any value, initialize it first outside the loop by giving it a value of either 0 or ""

Call to undefined function session_set() [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
My page returns this error:
Fatal error: Call to undefined function session_set()>in /home/a7714221/public_html/index.php on line 5
My code is long on the page that returns the error but the only thing that could cause it of course is the session_set()
Anybody know the fatal error that I've inadvertently made? :)
EDIt: I'm trying to pass variables across several pages. Specifically, take $_POST data, subtract it from another variable then ask the user to enter another value and subtract it from (previous post data - afore mentioned variable) and so on until it reaches 0.
There is no function session_set(), hence the fatal error. You tried to call a function that does not exist.
To set a session variable, you access it via the $_SESSION array.
So to set a $_SESSION variable, just like any other array
$_SESSION['foo'] = 'bar';
# Access a session var
echo $_SESSION['foo'] # Prints 'bar'
Further Reading from the docs

PHP script interrupted by variable [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I'm trying to create a news system.
I'm implementing the ability to edit the news.
But there is a problem, if i change the picture the system sends the change to mysql. but If you change only the text, as the title or description but not edit the image changes are not updated to databse.
if not change the image, the change does not come. because the variable "file" is empty.
Code:
form: http://ideone.com/e62q84
action: http://ideone.com/q3noFc
see above url for my code.
there is a way to continue entering data even if the user chooses to leave the variable "file" empty?
This is happened because may be you check like if(isset($_POST['file'])) so change this to any required filed i.e. if(isset($_POST['title'])) or you can check with button also like if(isset($_POST['submit'])). Hope this help to you. If your issue is different then please add your code so we can identify the bug with your code.

Categories