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
Sorry for changing the question
I'm trying to include another php file inside php, my code is like this
Ajax mysqli not working
The difference is
I change "$con = new mysqli("localhost", "root", "", "whatever");" with "include 'admin/connection.php';"
Without include it's working, but, after adding include it's keep giving me error :(
Is it just me, my code is wrong or ajax didn't support php include?
if 'admin/connection.php' contains Connection code to DB
use require require PHP instead of include
require will halt the script whereas include only emits a warning (E_WARNING) which allows the script to continue.
require('admin/connection.php');
and if your server is not connected to db how can you expect to run sql query
Related
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 6 years ago.
Improve this question
I am working on some sort of blogging platform in php with a nice material design lite frontend. However I have a page that dynamically loads the content, it works fine in the root directory, but not in my admin directory. I hope you can spot some kind of error/typo in my code, I know the error is in the menu-start file, since disabling it enables loading.
Here is the page that loads the code
and here is the menu-start page
If you need any other code, please ask
You're using relative links for include, which will mess up when you start changing directories. Use a pseudo-absolute path with DOCUMENT_ROOT. Be sure to use this for all of your includes.
<?php include $_SERVER['DOCUMENT_ROOT'].'/menu-start.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 7 years ago.
Improve this question
i would like to ask if someone had the same problem or know any workaroundto fix it.
I have a large file (15MB) full of array values which i find and read them.
On xampp the code with preg_match_all works correcly (for large and small files).
on the server Current PHP version: 5.5.9 (2 vcpu 2GB ram)
preg_match_all stop execution of the code (if i test with small file it gives correct results).
Try using:
ini_set('memory_limit','1024M');
In the beginning of the script.
Also, if you're calling the script from your browser, print an empty space on that loop to keep your browser alive.
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
I have a program I am currently trying to change from MySQL to MySQLi. The following database configuration is in one file:
<?php
define ("DBHOST","localhost");
define ("DBUSER","user");
define ("DBPASS","pass");
define ("DBNAME","name");
/*define ("DBUSER","root");
define ("DBPASS","");
define ("DBNAME","date_demo");*/
define ("DBPREFIX","");
define ("CHAR_SET","utf8");
define ("CACHEDIR","");
?>
The other section is on another page:
$conn = new mysqli(DBHOST,DBUSER,DBPASS) or die(mysqli_connect_errno());
$row = mysqli_fetch_array(mysqli_query("select * from settings where id = '1' "));
How can I get them all onto one page? Any ideas would be much appreciated so I can start converting to MySQLi.
by doing this, you are borderline mixing procedural and OOP php which is highly ill advised. If you want to keep the connection seperate, you can
include 'conn.php';
however i would highly reccomend looking into building a PDO object and running any queries via that. a useful tutorial can be found at https://www.youtube.com/watch?v=c_hNNAdyfQk&list=PLfdtiltiRHWF5Rhuk7k4UAU1_yLAZzhWc which introduces the concepts of using global variables and shows how to instatiate a DB object which creates a better structure for your code and abstracts functions from data.
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
I have a simple php connection to my database, I think i did most of the process right, but when I hit the submit button it just renders my actual php file on my screen.
Make sure you are using a web server that supports PHP. It is rendering the code because PHP is not processing your code and renders it as text.
Try using another web server or install PHP on your current setup.
Also use MySQLi or PDO for your database part (it's safer and mysql_* is deprecated).
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 8 years ago.
Improve this question
Putty executes my php script without error but no results. This script is supposed to run a query on the database and the send those results as excel file. Does anyone know what could cause this?
Try prepending your script with:
<?php
error_reporting(E_ALL);
?>
to output all errors. Failing that, you could put some debug in the code to find where it keeps failing.
Sometimes there is something in the PHP error log (/var/log/php_errors on Centos).