Friends I am using xampp software. I have created a database and then a php page. I know how to run the php page by using xampp but when I tried to connect php page with the database, I am getting an error.
Error(Warning: mysql_connect(): Host 'fe80::e15b:3b0:1257:7afe%13' is not allowed to connect to this MySQL server in C:\xampp\htdocs\sant\insert.php on line 4
Could not connect: Host 'fe80::e15b:3b0:1257:7afe%13' is not allowed to connect to this MySQL server).
I am using the hostname as localhost, even I tried with my pc name but that is not working. I have referred lot of sites but didn't get the exact answer.
somebody please help me to overcome this problem
you write code like following
<?php
$host = "localhost"; //your localhost name
$user = "xcode"; //your username
$pass = "xcode"; //your password
$db="xcode"; //your database name
$r = mysql_connect($host, $user, $pass);
if (!$r) {
echo "Could not connect to server\n";
trigger_error(mysql_error(), E_USER_ERROR);
} else {
echo "Connection established\n";
}
echo mysql_get_server_info() . "\n";
$r2 = mysql_select_db($db);
if (!$r2) {
echo "Cannot select database\n";
trigger_error(mysql_error(), E_USER_ERROR);
} else {
echo "database selected\n";
}
mysql_close();
?>
you try this code.
$db = new mysqli('localhost', 'root', '', 'database_name');
if (mysqli_connect_errno()) {
echo 'connect failed: '.mysqli_connect_errno();
} else {
echo 'connected !';
}
Try this and post the result
Related
So I am trying to use the SMS (text message) function in Laravel / Twilio - I have a local machine which I tested it on and the credentials and everything works fine- I use the same code on my remote machine (which worked fine yesterday) and today I am getting an error: "Error: Credentials are required to create a Client"
I have triple confirmed the credentials are correct, I have even hard coded them into the code , I have moved them from the env file to config file and still not working - I have retested my local machine and it works still - I have copied the code from local machine (working) to remote machine and still not working - the only difference between the two is I have changed the SMTP settings in the env file (even if I remove this , the problem still exists). I have cleared cache, restarted services.
my .env file
TWILIO_SID=xxxxxxxxxx
TWILIO_TOKEN=xxxxxxxxxxxxxxx
TWILIO_FROM=+1xxxxxxxxxxxxx
my Twiliocontroller:
public function smsSend()
{
$receiverNumber = "+111111111";
$message = "Sup Dude";
try {
$account_sid = getenv("TWILIO_SID");
$auth_token = getenv("TWILIO_TOKEN");
$twilio_number = getenv("TWILIO_FROM");
$client = new Client($account_sid, $auth_token);
$client->messages->create($receiverNumber, [
"from" => $twilio_number,
"body" => $message,
"statusCallback" => "https://webhook.site/xxxxxxxxxxxxxx"
]);
dd('SMS Sent Successfully.');
} catch (Exception $e) {
dd("Error: " . $e->getMessage());
}
}
My web.php
Route::get('/smssend', [TwilioController::class, 'smsSend'])->name('smsSend');
Any help would be greatly appreciated
I installed master login system in php, it works perfect in XAMMP but in server it gives error in register page:
"There was an error ! Please try again !"
if(($db->query("INSERT INTO `".MLS_PREFIX."users` SET ?u", $user_data)) && ($id = $db->insertId()) && ($db->query("INSERT INTO `".MLS_PREFIX."privacy` SET `userid` = ?i", $id)) && ($db->query("INSERT INTO `".MLS_PREFIX."privacy1` SET `chart` = '1', `vip` = '1', `userid` = ?i", $id))) {
$page->success = 1;
$_SESSION['user'] = $id;
$user = new User($db);
} else
$page->error = "There was an error ! Please try again !";
Don not include the dot in the backtics; the correct syntax is:
`dbname`.`tablename`
I'm running the following PHP code (a pretty simple one):
<?php
$servername = "192.168.0.54";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
It's returning the following error:
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\test.php on line 7
Connection failed: No connection could be made because the target machine actively refused it.
SQL is running (on Windows Server) and I can log in with the same credentials.
Help would be appreciated.
I m using Wamp Server (Local Host)
Error Message
A PHP Error was encountered
Severity: Warning
Message: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Filename: libraries/Email.php
Line Number: 1553
Controller
if ($this->form_validation->run() == TRUE)
{
//Email Verification
$key = md5(uniqid());
$this->load->library('email',array('mailtype'=>'html'));
$this->email->from ('info#worldquotes.in','Admin');
$this->email->to($this->input->post('email'));
$this->email->Subject('Confirm YOur Account');
$message = "<p> thank you for Signing Up </p>";
$message .= "<p> <a href= '".base_url()."main/register_user/$key '> Click here </a> to Confirm Your Account </p>";
$this->email->message($message);
if ($this->email->send()) {
echo "Then Email has been Send";
}else echo "Could ot send the Email, Contact info#worldquotes.in";
}
else
{
$this->load->view('signup');
}
}
May I know why that error message came and how to resolve?
You need to configure your server for mailing first. Take a look at this handy tutorial and you should be on your way.
http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html
If you're having trouble figuring out your ISP's SMTP server, you could take a look in this catalog:
http://www.arclab.com/products/amlc/list-of-smtp-and-pop3-servers-mailserver-list.html
Hope this helps!
Hey guys, I have a problem (again). This time I am trying to use NuSoap w/ XAMPP 1.7.1 which includes PHP5 and MySQL ... I wrote a soap-client:
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/mysql/helloworld2.php');
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Constructor error: ' . $err . '</b></p>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Doro'));
// Check for a fault
if ($client->fault) {
echo '<p><b>Fault: ';
print_r($result);
echo '</b></p>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Error: ' . $err . '</b></p>';
} else {
// Display the result
print_r($result);
}
}
?>
and my soap-server:
// Enable debugging *before* creating server instance
$debug = 1;
// Create the server instance
$server = new soap_server;
// Register the method to expose
$server->register('hello');
// Define the method as a PHP function
function hello($name) {
$dbhost = 'blah';
$dbuser = 'blub';
$dbpass = 'booboo';
try{
$conn = MYSQL_CONNECT($dbhost, $dbuser, $dbpass)
or die ('Error connecting to mysql');
if( !$conn ){
return 'Hello, '.$name.' ... too bad, I cannot connect to the db!';
}
else{
$dbname = 'soaperina';
MYSQL_SELECT_DB($dbname) or die('Error connecting to '.dbname);
$queryres = #mysql_db_query(
'response',
'SELECT * FROM farben');
return 'RESPONSE: <br>';
while( $arr = mysql_fetch_array( $queryres ) ){
return $arr["ID"]." - ".$arr["Farben"]." - ".$arr["Rating"]."<br>";
}
}
}
catch(Exception $e){
return 'Sorry, '.$name.', but that did not work at all!';
}
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
I know that PHP works, the Apache works, MySQL works ... it also works together, but when I try to make it work with NuSOAP it does not work. I get following:
Warning:
SoapClient::SoapClient(http://localhost/mysql/helloworld2.php)
[soapclient.soapclient]: failed to
open stream: Ein Verbindungsversuch
ist fehlgeschlagen, da die Gegenstelle
nach einer bestimmten Zeitspanne nicht
richtig reagiert hat, oder die
hergestellte Verbindung war
fehlerhaft, da der verbundene Host
nicht reagiert hat. in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 6
Warning: SoapClient::SoapClient()
[soapclient.soapclient]: I/O warning :
failed to load external entity
"http://localhost/mysql/helloworld2.php"
in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 6
Fatal error: Maximum execution time of
60 seconds exceeded in
C:\xampp\htdocs\mysql\helloworld2client.php
on line 41
I have no idea what that is supposed to mean. I hope ya'll can help!!! Thnx in advance :)
I used NuSOAP version 1.7.3 with PHP5. In this NuSOAP 1.7.3, soapclient class renamed by nu_soapclient.
You can try this:
$client = new nusoap_client('http://localhost/mysql/helloworld2.php');
to give an answer to my own question: nusoap has a problem with php5 ... there are some answers and some solutions on the net (not many), but they didn't work with me. I downgraded to php4 and it works fine ...