Fatal error: Uncaught Error: Call to undefined method mysqli::execute() - php

I am learning php. I am getting this error
Fatal error: Uncaught Error: Call to undefined method mysqli::execute() in C:\xampp\htdocs\search\index.php:58 Stack trace: #0 {main} thrown in C:\xampp\htdocs\search\index.php on line 58
Here the line 58 is
<?php
include'config.php';
$stmt=$conn->prepare("SELECT * FROM info");
$conn->execute(); // This line
$result=$stmt->get_result();
?>
I am trying to create a simple live search.

Call the method execute() on $stmt object instead.
include 'config.php';
$stmt = $conn->prepare("SELECT * FROM info");
$stmt->execute(); // you are executing connection here
$result = $stmt->get_result();

Related

Methods with the same name

My webpage gives the "methods with the same name as their class will not be constructors in a future version of php" error with the below code.
When I change the "function settings()" to "function __construct()", the web page gives a fatal error.
Fatal error: Uncaught Error: Call to undefined method validator::settings() in /home/mertcek1563/public_html/rmd2015/sdwf/validator.php:11
Stack trace:
#0 /home/mertcek1563/public_html/rmd2015/z_common.php(103): validator->__construct()
#1 /home/mertcek1563/public_html/rmd2015/z_core.php(22): include('/home/mertcek15...')
#2 /home/mertcek1563/public_html/rmd2015/index.php(2): include('/home/mertcek15...')
#3 {main}
thrown in /home/mertcek1563/public_html/rmd2015/sdwf/validator.php on line 11
How I can fix this code?
class settings
{
var $settings = array();
function settings(){
$this->settings["price"]=array();
$this->settings["price"]["dot"]=".";
$this->settings["price"]["decimals"]=6;
$this->settings["date"]=array();
$this->settings["date"]["delimiter"]="/";
$this->settings["date"]["format"]="dd/mm/yyyy";
$this->settings["number"]=array();
$this->settings["number"]["dot"]=".";
$this->settings["number"]["decimals"]=6;
}
}
Then I end up with fatal error:
Fatal error: Uncaught Error: Call to undefined method
validator::settings() in
/home/mertcek1563/public_html/rmd2015/sdwf/validator.php:11
<?
include_once("settings.php");
class validator extends settings
{
var $errors = array();
var $required = array();
function __construct(){
$this->settings();
}

Share PHP Rivescript object into $_SESSION

I have a issue trying to save an object into session.
From my index.php I create the object and store it into session:
include_once __DIR__.'/vendor/autoload.php';
use Axiom\Rivescript\Rivescript;
$test = new Rivescript();
$test->load(realpath(__KNOWLEDGE__));
session_start();
if (isset($_SESSION['ENGINE'])){
unset($_SESSION['ENGINE']);
}
$_SESSION['ENGINE'] = $test;
in another php page I recall the session to get te object:
session_start();
if (!isset($_SESSION['ENGINE'] )){
// error
}else{
$test = $_SESSION['ENGINE'];
$txt = $test->reply($input,$client_id);
}
This page is called by AJAX.
and I get this error:
Notice: Trying to get property 'memory' of non-object in /var/www/html/vendor/axiom/rivescript/src/Cortex/Input.php on line 64
Fatal error: Uncaught Error: Call to a member function substitute() on null in /var/www/html/vendor/axiom/rivescript/src/Cortex/Input.php:64 Stack trace: #0 /var/www/html/vendor/axiom/rivescript/src/Cortex/Input.php(33): Axiom\Rivescript\Cortex\Input->cleanOriginalSource() #1 /var/www/html/vendor/axiom/rivescript/src/Rivescript.php(34): Axiom\Rivescript\Cortex\Input->__construct('ciao', '5e5fe0688782a') #2 /var/www/html/include/bot.php(24): Axiom\Rivescript\Rivescript->reply('ciao', '5e5fe0688782a') #3 {main} thrown in /var/www/html/vendor/axiom/rivescript/src/Cortex/Input.php on line 64
Any help ??

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1036 Table 'signup' is read only

I am new to coding, trying to create a simple registration form using php and mysql ..but this error I dont know Why it says the table is read only can somebody help me fix it
This is the error
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1036 Table 'tablename' is read only in C:\xampp\htdocs\Laravel\Project\public\classes\DB.php:15 Stack trace: #0 C:\xampp\htdocs\Laravel\Project\public\classes\DB.php(15): PDOStatement->execute(Array) #1 C:\xampp\htdocs\Laravel\Project\public\create-account.php(14): DB::query('INSERT INTO sig...', Array) #2 {main} thrown in C:\xampp\htdocs\Laravel\Boss\public\classes\DB.php on line 15
and this the DB.php file
class DB{
private static function connect(){
$pdo=new pdo('mysql:host=127.0.0.1;dbname=boss;charset=utf8','root','');
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
return $pdo;
}
public static function query($query,$params=array()){
$statement=self::connect()->prepare($query);
$statement->execute($params);
//$data = $statement->fetchAll();
//return data;
}
}

How to select multiple query and retrieve them

When I retrieve two tables there's an error. What is the problem with my code? I have no idea how to fix this
<?php
include ('includes/config.php');
$mysqli = new mysqli(DB_SERVER, DB_UNAME,DB_PASSWD,DB_NAME);
if(!$mysqli){
throw new Exception($mysqli->connect_error, $mysqli->connect_errno);
}
$jqry = $mysqli->prepare("SELECT time FROM table_time ORDER BY time");
if (!$jqry){
throw new Exception($mysqli->error);
}
$jqry->execute();
$jqry->bind_result($time);
$jqry->store_result();
$times = array();
while ($jqry->fetch()){
$times[] = $time;
}
$jqry->close();
$gqry = $mysqli->prepare("SELECT table_group.group FROM table_group.table_group ORDER BY group");
if(!$gqry){
throw new Exception($gqry->error);
}
$gqry->execute();
$gqry->bind_result($group);
$gqry->store_result();
$groups = array();
while ($gqry->fetch()){
$groups[] = $group;
}
?>
This is the error I got:
Notice: Trying to get property of non-object in C:\xampp\htdocs\~Jeremiah\system5\joborder.php on line 31
Fatal error: Uncaught exception 'Exception' in C:\xampp\htdocs\~Jeremiah\system5\joborder.php:31 Stack trace: #0 {main} thrown in
your SQL just before the line 31 is invalid. Try executing it against db directly.
from the manual:
mysqli_prepare() returns a statement object or FALSE if an error occurred.
...and thats why we don't suppress notices in dev enviroment! :)

How to fix error returned by __soapCall?

$param['websiteConfigID'] = 729872;
$param['numberOfRecords'] = 10;
$param['numberOfRecords'] = 10;
$client = new SoapClient(WSDL);
$result = $client->__soapCall('GetTicketsStringInputs', array('parameters' => $param));
$result holding this error message....
Fatal error: Uncaught SoapFault exception:
[Client] Function ("GetTicketsStringInputs") is not a valid method for this service in /home/fmticket/public_html/inc/genericLib.php:279
Stack trace:
#0 /home/fmticket/public_html/inc/genericLib.php(279): SoapClient->__soapCall('GetTicketsStrin...', Array)
#1 /home/fmticket/public_html/resultsTicket.php(12): getTickets(Array)
#2 {main} thrown in /home/fmticket/public_html/inc/genericLib.php on line 279
how to resolve it?? plz help.
Your code is calling the remote GetTicketsStringInputs function :
$client->__soapCall('GetTicketsStringInputs', ...
The Fatal error you get indicates :
Function ("GetTicketsStringInputs") is not a valid method for this service
It seems pretty clear : the method you're trying to call doesn't exist, it is not provided by the remote web-service.
So, to fix that Fatal Error, you have to stop calling that function ;-)
You should check the WSDL of your webservice : does it really export such a method ?

Categories