mysql_connect() fatal error [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 7 years ago.
Improve this question
I have a problem, when I write my welcome.php I need to use mysql_connect() but when I run it, an error appears:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/u781677053/public_html/cas/welcome.php:4 Stack trace: #0 {main} thrown in /home/u781677053/public_html/cas/welcome.php on line 4
I'm using a web called Hostinger.es, not apache, or any stuff
The code:
mysql_connect("localhost","u781677053_lo","987654") or die();
mysql_select_db("u781677053_po") or die();

mysql_* is now deprecated . Use mysqli_* OR PDO
You can do it like below in mysqli_*:-
$connect = mysqli_connect("localhost","u781677053_lo","987654","u781677053_po") or die(mysqli_connect_error());

Related

Call to undefined function set_magic_quotes_runtime() [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
So, on my website I'm getting this error:
Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /homepages/4/d661770438/htdocs/awptical/initdata.php:382 Stack trace: #0 /homepages/4/d661770438/htdocs/awptical/index.php(21): require_once() #1 {main} thrown in /homepages/4/d661770438/htdocs/awptical/initdata.php on line 382
Does anybody know what this means?
The function no longer exists in PHP 7, nor the setting it works with, so you will need to remove its usages. You will need to save the current state of your code and try to remove all the instances of this function call and see whether the site is working and if so, whether it is working as you expect it to work. Alternatively, you can implement a dummy version of the function and make it available everywhere:
if (!function_exists('set_magic_quotes_runtime')) {
function set_magic_quotes_runtime($new_setting) {
return true;
}
}
You are using PHP version 7.x.x, at which set_magic_quotes_runtime() was removed.
This function was DEPRECATED in PHP 5.3.0, and REMOVED as of PHP 7.0.0.

PHP Catchable fatal error: Argument 3 passed to [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 6 years ago.
Improve this question
Catchable fatal error: Argument 3 passed to Account::updateUser() must
be an instance of , string given, called in
/Applications/XAMPP/xamppfiles/htdocs/myPage/beta/Includes/includes.php
on line 27 and defined in
/Applications/XAMPP/xamppfiles/htdocs/myPage/beta/classes/Account.php
on line 214
Line 27:
$Account->updateUser($_SESSION["username"], $_POST["password_check"], $_POST["pw1"], $_POST["pw2"]);
Line 214:
public function updateUser($session, $password_check, $pw, $pw2){
How may I fix this? I've tried to rewrite the code multiple times, and tried to change everything on line 214 and below. Also tried to change some of line 27, cannot find the problem and have googled for a long time.
I think there is an invisible character (something like an unbreakable space, or some other invisible utf8 char) in your function declaration and php think it's type hint. You could delete the line and rewrite it. I thnik the probleme is here because must be an instance of , means php want a variable of type "".
Delete and rewrite the function declaration (no copy/paste)

Fatal error: Function name must be a string whilst it shouldn't [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
I have stumbled over the following error in PHP:
"Fatal error: Function name must be a string in
F:\Applications\xampp\htdocs\BTB_Sandbox\uploads.php on line 15"
and I don't know what the real problem is. Here is line 15 that the error is pointing at:
$error = $_FILES(['file_upload']['error']);
I hope you could help me, because I am kind of stuck now.
You are using $_FILES as a function because of ().
That way, PHP tries to call a function named as var $_FILES value, but this value it not a string (that's the error reported), it is an array.
Obviously, in your code line you are failing to use $_FILES, the right way is:
$error = $_FILES['file_upload']['error'];

Weird PHP "Fatal error: Cannot redeclare" Error [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 8 years ago.
Improve this question
My script is returning the following error...
Fatal error: Cannot redeclare connecttodatabase() (previously declared in /var/www/api/connecttodatabase.php:4) in /var/www/api/connecttodatabase.php on line 6
And the following is the connecttodatabase.php file...
<?php
function connecttodatabase()
{
$con = #mysqli_connect("localhost", "name", "password", "database");
return $con;
}
?>
I don't really understand this error because line 6 is just the closed curly bracket (})
I think the error means that it thinks I declared the function connecttodatabase() in to different spots but clearly I didn't.
As others have said in the comments, this is most likely because you have included connecttodatabase.php twice in your code, and you are certainly defining the function twice. Don't get hung up why it's line 6; line 2 would be more helpful, but line 6 is where the function definition ends, and so arguably is when the function is defined. You could have a "one a day" whole year calendar on the idiosyncrasies of PHP and have enough left over for a sequel. As others have also hinted, some basic debugging would confirm whether you are including the file more than once and also from where.
Make sure that your code uses include_once or require_once.

Undefined index Error and query not running? [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 8 years ago.
Improve this question
I am getting this error
Notice: Undefined index: maxvalid in C:\wamp\www\myproj\includes\func.php on line 26
and my code is
require("common.php");
$incquery = "select max($TabFld) as maxvalid from $TabName";
$stmt = $db->prepare($incquery);
$incresult = $stmt->execute();
$row=$stmt->fetchAll();
$maxvalid = $row['maxvalid'];
if($maxvalid <> NULL)
{
$incvalid=$row['maxvalid']+1;
}
return $incvalid;
I am using PDO to connect mysql and I never used it before. I always use mysql_connect to connect database and I cannot understand why I am getting this error.
I also debug the code and see that value is not coming in $maxvalid variable but it came when I use mysql_connect.
fetchAll returns an array of rows. Try just fetch
For future reference, if in doubt, var_dump it.

Categories