No Connect Server when run indexphp on MAMP - php

I have to tell you guys first that I'm a newbie of web development but I just got an assignment to maintain website. I copy all important files on server and set my computer to be a localhost with MAMP. After I try to run page index.php on browser but it show me a result like "NO Connect Server". I dont get it why it show me like that. I has tested my localhost by create test.php to do something for testing like echo and it works fine.
Does anyone know how can I fix this problem?
Thanks,
regards

From what it looks like, there is no real way to tell what the real problem is. The only things I can think of are the usual ones: the MySQL server isn't actually running, the user name or password is wrong, or the user name isn't actually registered in the system. Sorry that I can't give more details, but you could find more information if you replace the NO connect Server with mysql_error() like this:
$db = mysql_connect('localhost','username','passwort') or die(mysql_error());
That will print out the error text when the script dies. With that information, you can start to decode what is actually going on.

Related

Connecting sqlite db on server

So I have a website created with html, javascript, sqlite, and php. It runs fine on localhost. I moved it to an actual server and now it wont load because the path to the database is different and I'm not sure how to fix it.
I have tried changing the link but the server folder has '\' in it so php doesnt seem to like that.
The PHP code is below:
On localhost it was
$database_name = "/Applications/MAMP/htdocs/proj/db/radar.db"
the path to the server is "\proj\company.net$"
I tried $database_name = "\\proj\company.net$/db/radar.db"
It just doesn't load anything an I know the back or forward slashes are throwing it off but i'm not sure how to fix it. Any help is greatly appreciated.
You need to scape the backslashes.
if you need \\proj\company.net$/db/radar.db
then your code should look like this:
$database_name = "\\\\proj\\company.net$/db/radar.db";

Hard time to connect to my database with php

I am trying to build a homne server for studies on a raspberry pi 3.
I am just trying to connect to my raspberry database and php base to use my database on a HTML page.
I tried everything 9not apparently), to change several times my login, i tried with 'root' and create an other user and give all privileges etc, but nothing seem to work. I have all installed, php work just fine, i can reach my server with a domain name hosted by noip. the html and php content pop just fine.
I can even connect to my database via ssh.
But since few month i tried to make it work and i am desesperate, so if someone can help me ...
<?php
$db = mysqli_connect("mywebsite","root","myLogin","mydbName")
or die(mysqli_error($db));
?>
so i would just be able to make request on my database, i am just blocked on that step
$con=new mysqli("localhost","root","root_password","database_name");
Generally, root has no password so the connection should be like this
$con=new mysqli("localhost","root","","database_name");

How to setup Database connection using php coding and where to save that file?

I am having some problems with php coding i have written php coding correct but it is not working,it is giving an error that "The Object not found" in browser.
Hey guyz please help me i am stuck on this and tried every possible thing to make this coding work.
Thanks
First php is not supported by itself in browser, you need a server to run php,you can use a localhost server like wamp, create DB in phpMyAdmin panel with the desired username and password then you can connect to it from your classes.
$this->host="localhost";
$this->username="root";
$this->password="";
$this->database="dbname";
$con=mysql_connect($this->host,$this->username,$this->password) or die(mysql_error());
$res=mysql_select_db($this->database,$con)or die(mysql_error());
you can save the file in any folder but it is advisable for u to save it in where all your files are kept for a quick reference.
below is php code for setting up database:
$con=mysqli_connect("host","user","password") or die(mysqli_error());
mysqli_select_db($con,"yourdatabasename");
Note:
host=localhost(if wamp or xampp is used) or your domain name(like www.google.com)
You can save dis php file with any name e.g config.php.
user= username of your database used in your phpmyadmin. likewise your password.
If you are using wamp or xampp, use dis format:
$con=mysqli_connect("locahost","root","") or die(mysqli_error());

How to execute xpdf (pdftotext.exe) on shared drive?

im trying to parse pdf to text via PHP and XPDF (pdftotext.exe). On my localhost everythings works well, but when im trying to move everything on server, im getting into troubles.
First of all i checked some settings on server and safe_mode is off, exec is not disabled and permissions are rwxrwxrwx.
Then im trying this
$command = "\\\\149.223.22.11\\cae\\04_Knowledge-base\\tools\\pdftotext.exe -enc UTF-8 ". $fileName . " \\\\149.223.22.11\\cae\\04_Knowledge-base\\output.txt";
$result = exec($command,$output,$args);
echo shell_exec($command);
which isnt working. When i look into $result, $output, are empty, but $args returns 1 which coresponds to Incorrect function by this document windows system error codes
Whole command looks like \\149.223.22.11\cae\04_Knowledge-base\tools\pdftotext.exe -enc UTF-8 \\149.223.22.11\cae\04_Knowledge-base\testpdf\04_egerland_final_paper.pdf \\149.223.22.11\cae\04_Knowledge-base\output.txt and when is dirrectly inputed into commandline, its working.
So im a bit out of ideas. Have someone any hint?
edit 20160201 - aditional trying
So i made aditional tests and when im trying to run similar command with exec from localhost (target .exe file, input and output file is in same location, only im using localhost not server) its working. Im now checking differences in server settings. So can here be problem, that localhosts Server Api is Apache 2.0 Handler and server is CGI/FASTCGI?
So it was all mistake on my side. I badly checked IIS permissions and forgot to assign user to virtual directory which i wana to access. So my only advice and more wisdom from this is to double (maybe triple) check if you have all permissions set correctly.

PHP MySQL fails when page is viewed remotely

I have two servers on my local network - one a web frontend and the other a MySQL backend. I have a PHP script that looks like this:
<?php
error_reporting(-1);
echo "Connecting...\n";
$link = mysql_connect("192.168.1.15", "-----", "-----") or die(mysql_error());
echo "Communicating with the server...";
mysql_query("INSERT INTO .....
//More code down here...
?>
This script is called on my web frontend to connect to the backend server. When this script is accessed from the local network (i.e. when I open the page by going to http://192.168.1.14), the script outputs
Connecting...
Communicating with the server...
and a row is added to the database, as it should. However when I connect remotely (i.e. going to http://myDomainName.com/mysql_insert_script.php) from a connection not on the local network, all I see is:
Connecting...
No error messages follow, the script just cuts off, and no data is added to the database. When I place a second, 'proxy' script on the server that simply requires() the above script and then I access the proxy remotely, everything works fine. Below is the proxy script, so you can get a better idea of what works and what does not:
<?php
//this script makes it appear that the mysql_script is being viewed from the local network
//I exist on the web frontend at 192.168.1.14
require("http://192.168.1.15/mysql_insert_script.php");
?>
I am sorry if I can't provide any more information, but I am stumped. Any help would be appreciated.
Chris
P.S. - I have verified that the mysql server is accessible from external hosts on the local network, but I have a firewall that prevents connections from outside my network. I don't think this would matter, however, as the MySQL server and the PHP script connecting to it are both run on the local net.
you got wrong server name

Categories