Python and PHP use the same mySQL database - php

I have a script in Python that retrieves data from a remote server into a MySQL database located on my computer (the one that runs the Python script).
This script is executed daily to retrieve fresh data into the MySQL database. I am using Workbench 6.0 for Windows 64.
I want to add a web GUI to the system that will present some of the data on a web page. I would like to write it in PHP and for my PHP program to use the same MySQL database that my Python script uses. I would like to make it a web server later on so users can log in to the sever and use this web GUI.
Can the PHP and the Python scripts use the same DB?
In the past I have worked with WAMP sever for PHP only. If I install WAMP on the sever, will it be able to use the same DB or can it cause a collision?

I'd comment, but I don't have enough rep. yet. You should be able to start the Apache and PHP services separately from the WAMP tray icon. If you can't, try this:
You should be able to use the WAMP menu on the tray icon to open WAMP's my.ini file. In there, just change the port number from 3306 to something else (might as well use 3307) and save the file, then restart WAMP. In the future, completely ignore WAMP's MySQL instance and just use the one that Python is connecting to.
If that still doesn't work, you might have Skype running. By default, Skype listens on Port 80 for some bizarre reason. Open Skype's settings, go to the "Connection" section and untick "Use port 80 as an alternative for incoming connections." Then try restarting WAMP again.

Related

Can PHP trigger an event on a remote Windows Server

Is there a way for PHP to send a signal to a Windows Server to run a script?
I am writing a web application which generates database entries that are later synced by a program on a remote Windows Server. PHP & mySQL are running on AWS.
The application on the windows server syncs the mySql database with Quickbooks. Ideally I would like to send a signal from PHP so that if PHP has updated the database, letting the remote Windows server know which script to run to in order to initiate the sync program. I would need to be pointed in the right direction both on the PHP commands as well as how to setup the listening service on Windows.
I was thinking if I could get Windows to listen on a specific port for a short XML file, PHP could send a password and entity ID number to identify which script to run.
Any suggestions?
Thanks!
You can use php on both end. Just install php server on windows, then when request happened execute a windows command. Php can do that.
I would schedule a task to read a specific file from the windows server side and from the php side you could use cron jobs. This question is too broad though and there are several approaches to that. You need to be more "code" specific.

How to connect to SQLYog localhost or otherwise

I am new to working with servers, and am not able to use SQLYog because it is not able to connect to any server. When I try to use the default values to connect to MySQL (localhost, root, port 3306), I get "Error No. 2003: Can't connect to MySQL server on 'localhost' (0).
Is there something I am missing or that I have to correct? I am just trying to create a database.
SQLyog is just one way to connect to a MySQL database and interact with it. Other popular methods include MySQL Workbench, Navicat, phpMyAdmin, and others.
Before you can use any of these, you have to first make sure your MySQL server is running and accepting connections. You didn't mention (or tag) whether you are running MySQL on your local machine, or what operating system you are using.
A couple of the most common development environments are LAMP or WAMP, for "Linux, Apache, MySQL, php" or "Windows, Apache, MySQL, php" respectively. Since you tagged your question php, I'll assume one of these is appropriate. (For example you're using SQLyog on Windows but your MySQL server is on Linux.) (I'll presume Ubuntu for Linux examples.)
On the machine you've installed MySQL (along with any other components), you should be able to determine its running state by looking at your process list (ps aux in Ubuntu, tasklist or Task Manager (GUI) in Windows).
You're looking for mysqld (Linux) or mysqld.exe (Windows). If the process isn't running, you need to start it (Linux/Windows). If you're using WampServer (a popular Windows all-in-one package), for example, you can also look in your Windows Services for "wampmysqld" or "wampmysqld64" and start the service there.
If you can't get the process to start, you may have a configuration error. If the process is running, you may need to check the configuration any way to determine what port it is running on, if it's not the standard 3306.
The configuration file name and location can vary by system and package, but generally it will be called "my.cnf" (Linux) or "my.ini" (Windows). Check your documentation for help on the specific path.
Once you've got the service running, you should be able to connect!
This is the default SQLyog connection dialog (at least in my slightly older version). The defaults assume you are running your MySQL server on your local machine (localhost), that you have a user "root" with no password, and the default port 3306 is used.
You'll need to change any of this information that differs on your particular installation.
Be aware that if you're trying to connect to an instance of MySQL on another machine, a firewall may be blocking a port.
These steps should hopefully get you on the right track.

PHP exec() , showing executed exe file in task manager but not displaying

i have used simple PHP script to execute exe file through php script, below is my PHP code
<? exec('"C:\Windows\notepad.exe"');?>
my problem is, when i check task manager after executing above code, notepad.exe is there but it is not diplaying
same way if i execute below mentioned code
<? exec('"C:\Program Files\WinSCP\WinSCP.exe"'); ?>
task manager shows WinSCP.exe, but winscp is not diplaying
can anyone tell me why applications are not showing ?
Whatever your web server is (Apache, Nginx, IIS...) it's clearly not configured to run with the credentials of your administrator user account. That's the sensible default. Background services are designed to run unattended.
You have several choice, from worse to better:
Kill security in your web server configuration. If web server runs as service, open Windows Service Manager and configure it to run with your account (don't forget to come back here if you change your password in the future). This way you allow any stranger in your computer, local network and/or internet to run programs in your name, in this case Notepad and WinSCP.
If the web server allows it, run it from a command-prompt in your own session. It's similar to #1 but will at least not run 24/7.
Any of the above, with a restricted account.
Don't use a web server. PHP can run from the command-line just fine, what means that you can even create a *.bat file and assign an icon to it.
As about your code, when it finally works your script will sleep until you close Notepad. This can be a bug or a feature depending on your needs.
Had the same problem with WAMP 2.4 & windows XP, the following helped:
Win+R, services.msc
edit wampapache and wampmysqld to allow affecting desktop.
Alternatively you can try:
Win+R, services.msc
edit wampapache and wampmysqld to log on as the same user.

Wamp server is not working although it is showing green icon

I have been developing a php project and the wamp server was seems
working fine but suddenly it stops working and i don't know what to do
because when i check its status it says server online and green icon is also
showing but it just does not work whenever i run .php files, Mr. browser
just write it down as i did in notepad++ but before some days it was working
fine, please help me I'm kinda stuck?
I also want to mention that in the mean while I installed tomcat server for some other work is it anything to do with fault because i'm pretty sure both operating on differnet port numbers
use <?php instead of <?or left click wamp > php > settings > short_open_tags
and make sure you are running your scripts through localhost and not just opening the php file in the browser
Read More about wamp problem
If you're definitely viewing the script through your MAMP setup (if your URL bar starts with http:// instead of file://) and it is showing the contents of the PHP file instead of executing the script, it sounds like Apache is running fine, but PHP-FPM is the issue or a misconfiguration between the two. Apache should detect it is a PHP script and ship it to the PHP-FPM process, accept a response then ship it to your browser.
I would recommend checking PHP-FPM logs first. All logs are in MAMP/logs - scroll to the bottom of each one for latest entries. Ensure the service is running as expected and logging hits when Apache serves a .php file. PHP-FPM may be using a socket file (which can hit permission problems) or on a network port (which can be in use/require admin privileges/etc). Otherwise check your config files, or re-install MAMP for fresh config files.
If Apache cannot start, common reasons are;
The port is in use by another application
The port is a low number and you do not have administrator privileges to use that port
Switching from wired to wireless / switching network adapters / changing hostname, etc
Apache is already running, or Apache thinks it is
You must sign out from Skype it'll occupied the port of Apache or you should turn down the server and then restart you pc and turn it on. It will work fine.

SQL server database on mac (replacing remote with localhost)

I have a software application that is designed to save data to a remote sever, by using the following URL:
http://130.228.263.2/projectName.php
The application itself creates tables, stores data, etc... so I don't have to worry about that.
I have set up MySQL Server on my Mac as well as MySQLworkbench to see the database visually.
My question is: Should I simply replace the above URL with the following?
127.0.0.1.3306
to have the application data written to my Mac's database instead of the remote one, or are there any other steps (or different format for local host, etc...) that I should be taking as well?
On the Mac Apache + PHP are installed by default, so it's not necessary to install anything. Just copy the php application to your local machine, adjust the db settings as MasterOdin wrote and you should be fine. Of course the php app must be accessible by your local Apache (you have to switch it on, via Internet Sharing in the system settings panel). In order to have a good starting point I recommend that you use MySQL Workbench to migrate your remote db to the local machine (see menu Database -> Migration Wizard).
Unless the server can connect/view your local system (which is unlikely off the bat and would require more configuration), you would need to locally host the php file locally using MAMP, then open projectName.php and edit the MYSQL connection details within that file to point to 127.0.0.1.3306 (which should probably be 127.0.0.1:3306 as that last number is the port information?).
This would then write to your local DB setup.

Categories