How am I going to fix this problem? I tried many methods to solve this one but none of them work.I already changed the default value on each forms,still the same. Need some advice here. Thanks!
enter image description here
try this->
$con=new MySQLi("localhost","root","pwd","db");
try
{
if($con)
{
echo "Db connected successfully"
}
else
{
die("Error In Establishing Db Connection");
}
}
catch(Exception $ex)
{
echo $ex->getMessage();
}
then after include this connection file in other where u need it use $con object to fire queries and get results.Also Check your wp.config file for credentials and database and also for localhost
Related
I am using the following code in my file
require ABSPATH.'wp-admin/includes/class-ftp.php';
$ftp = new ftp();
$ftp->Verbose = TRUE;
$ftp->LocalEcho = TRUE;
if (!$ftp->SetServer(self::$form_vars['host']))
{
$ftp->quit();
die("Setting server failed\n");
}
if (!$ftp->connect())
{
die("Cannot connect\n");
}
if (!$ftp->login(self::$form_vars['user'], self::$form_vars['pass']))
{
die("Login failed\n");
$ftp->quit();
}
I am not able to login, it says Login Failed.
The same FTP works with Filezila. but not works using the script default wordprss ftp class.
It gives the following error also
GET < 421-Sorry, cleartext sessions and weak ciphers are not accepted on this server.
421 Please reconnect using TLS security mechanisms.
Any solution.
I have a file command handling data add database . I use Document Symfony 2.8 Process for the handling in the controller.
Everything was running fine. But I got an error . In the file command I use if-else to check data. When processed and running $process->run() , I cannot get the error in else (in else. I use echo to show the error).
if (!empty($id)) {
// handling code
} else {
echo "not found Id"
}
Do you have any ideas? help me please !
Document i use : https://symfony.com/doc/current/components/process.html
Normaly you can get the output of the process by using : echo $process->getOutput(); or in your case you can throw exception like
if (!empty($id)) {
// handling code
} else {
throw new \Exception('Id not found');
}
and put your process within try catch block like that
try {
$process->mustRun();
echo $process->getOutput();
} catch (\Exception $exception) {
echo $exception->getMessage();
}
Trying to select data into php page running on local Mac MAMP environment from sqlite file of my Things database.
Both DB connection & select code below and Things.sqlite files are located in same directory on the machine.
Getting "SQLSTATE[HY000]: General error: 1 no such table: TMTask" error though there's clearly such table as visible on the screenshot of viewing file in Base app.
Screenshot
<?php
try {
$db = new PDO("sqlite:".__DIR__."Things.sqlite3");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $e) {
echo "Unable to connect to database";
echo $e->getMessage();
exit;
}
try {
$results = $db->query("SELECT * from TMTask");
echo "Retrieved results.";
} catch (Exception $e) {
echo "Unable to retrieve results: ".$e->getMessage();
//exit;
}
var_dump($results->fetchAll());
?>
Thanks #your-common-sense! It helped. I figured out there was missing "/" in the file path.
I want to assign specific information for the server's characters and as well as the client's characters. Now, how do I know if the player is the host or the client? I tried using isServer and isClient, but it both return true. Are these the correct keywords that I should use?
void Update () {
if(isServer){
Debug.Log("I'm the server");
}
if(isClient){
Debug.Log("I'm the client");
}
}
If you're connecting as a "host", you're actually both the "client" and "server" at the same time. This is in contrast to running a "dedicated server", which acts as the server authority, but doesn't represent a "client" connection. Like you suggest in your own answer, you can use isServer and !isServer, or probably:
void Update() {
if (isServer) {
Debug.Log("I'm the server (or host)");
} else {
Debug.Log("I'm the client");
}
}
Instead of using isClient to determine if player is the client, i use !isServer instead.
void Update () {
if(isServer){
Debug.Log("I'm the server");
}
if(!isServer){
Debug.Log("I'm the client");
}
}
Not sure if this applies to every situation, so I apologize if it does not - I am using a plugin called NATTraversal for Unity, and I was having a similar issue. I needed to find which connection is the host. However for me, since I am not using the relay servers (this is for you guys who are avoiding the relay) I found that I can do this check..
using UnityEngine.Networking;
void Start(){
if(NetworkServer.connections.Count > 0){
Debug.Log("This is the host.");
} else {
Debug.Log("This is a client.");
}
}
This works in my scenario because the client's connection list is empty, but the host's is not. There very well may be a better way to do this, but I didn't know of one without a previous built list of NetworkIdentity's.
The Network.isServer bool always returns false for me, so this is how I got around it. Hopefully it helps someone out there.
Edit: (Adding crucial information)
Please note, that this is AFTER matchmaking and connections have been established.
Another way to do it I have found is by listening to OnServerConnect in the NATLobbyManager.
public override void OnServerConnect(NetworkConnection conn){ }
That event only triggers for the host with the NATTraversal plugin, more info for anyone who may come across this while trying to figure all this stuff out. :)
I have written the following code for login:
Session["IsLogin"] = false;
System.Configuration.Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
if (txtPassword.Text.Trim() == string.Empty)
{
// Display Error
}
else
{
string Pwd = config.AppSettings.Settings["PWD"].Value.ToString();
FormsAuthenticationTicket formAuthTk = FormsAuthentication.Decrypt(Pwd);
string strDcryptedPwd = formAuthTk.Name.Trim().ToString();
if (txtPassword.Text.Trim() == strDcryptedPwd)
{
Session["IsLogin"] = true;
Response.Redirect("AnyPage.aspx");
}
else
{
// Error, Wrong password
}
}
Which is running fine while running through Visual studio. But when I published it it is showing the below error:
System.Web.HttpException: Unable to validate data
NOTE:
I publish the application on the
same server on which I am developing
the site.
I have tried EnableViewStateMAC =
false on page level. [Login Page]
What is the reson of this error? Why it is only appears when I have published the site?
I have changed the way to encrypt the string and the problem disapperars. I have no idea about the reason of the error, but I resolved it like this.
Hope it will help to others, who are facing the same issue.
you do not need to declare the config in the way you did, just use Configuration.AppSettings["PWD"].ToString()...
see here:
How to: Read Application Settings from the Web.config File