PHP - Windows Server 2012 Question
Before reading, just know I am NOT a PHP programmer and have no experience with PHP. I am just trying to install a premade php based website.
My questions is: How do I make .php pages connect to my database?
I know the question is very broad and probably doesn't really make sense but I've been having errors trying to install/configure a php website. The php website has a config which I have filled out correctly and seems to work on my PC via localhost using XAMPP fine but it doesn't work on my Windows Server 2012 Apache machine whenever the .php configuration tries to alter or conenct to the MySQL database it displays errors like this:
Fatal error: Call to undefined function mysql_connect() in C:\Apache24\htdocs\includes\classes.php on line 378
That's just an example of one predefined PHP website errors that I've received they are all very similar. What I think is happening is the PHP code is trying to connect to the database but there's some sort of configuration variable on Apache that I have not correctly filled out. I have tried this twice with two different CMS and searched google far and wide to find an answer to my problem. I hope the answer is something simple. If you need anything because you think you know what is happening then I will provide any information needed to fix this problem.
Thank you.
Similar TutorialsI have a PHP web system that store in a windows server. In the system, there is a function for user to upload files to another server (Shared server in Unix). When i try to upload a file, it gives warning: Warning: move_uploaded_file(\\unixserver/sharedfolder/upload/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\upload\index.php on line 40 For your information, my username has been assigned in xxx's group that has access to read and write on that folder. Besides, i'm able to open,create and delete files on that folder's server manually (samba). The safe mode setting is off. Does anybody has any idea why this thing happen? Do you need to compile your own version of PHP with SSH extensions in order to use SSH with PHP running on a Windows Server? I set up functionality for a client that got moved to their server after I wrote and tested the functionality. It does not work on their server and I am trying to trouble shoot the problem as I do not have ftp access to the server.
I believe that I have narrowed it down to either I do not know how to access the temp files on their server, Windows IIS, OR the security on the server is not allowing me to upload to the temp files.
Here is the form used to upload to the server.
<form enctype="multipart/form-data" action="#" method="post" > <input type="hidden" name="upload_csv" value="TRUE" /> <p><label for="userfile">Upload CSV:</label> <input type="hidden" name="MAX_FILE_SIZE" value="45000000" /> <input type="file" id="userfile" name="userfile" title="userfile" value="" /></p> <p><input type="submit" name="upload_csv" value="Upload CSV" /></p> </form> Here is the test code: <?php $csvfile = $_FILES['userfile']['tmp_name']; $size = $_FILES['userfile']['size']; if($_POST['upload_csv']){ //---------------------------------validation code here if($problem){ echo '<div class="error">Did not pass validation</div>'; include("upload_csv.inc.php"); }else{ if (($handle = fopen($csvfile, "r")) !== FALSE) { //--------------------------------------------------------------this is where the code that imports the data from the csv and to the database goes echo '<div class="message"><p>CSV has been opened!</p></div>'; }elseif(!$csvfile){ echo '<div class="error">Problem #1</div>'; }else{ echo '<div class="error">Problem #2</div>'; } } }else{ include("upload_csv.inc.php"); } ?> This code generated the error message: Problem #2. One more bit of information: the permissions on the server is set so that nothing can be uploaded by an external script. I do not know much about servers, but it seems to me that because the security is so tight on the server, the security is the reason that this does not work...??? I appreciate help with this. I just am not knowledgeable on how the $_FILES['userfile']['tmp_name'] code actually works? This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=352526.0 I have a PHP script containing the function exec which works fine in PHP 4 in IIS 7 on Windows 7. However this function does not work in PHP 4 in IIS 5 on windows server 2003. But I have to make it work there because that is what we have on our web server. Can someone provide a solution? This topic has been moved to Installation in Windows. http://www.phpfreaks.com/forums/index.php?topic=318822.0 Problem: My query is set to get rows with date after x, as of today (January 1st, 2012) my query doesn't recognize 01/01/2012 as greater than day 12/31/2011. Webpage: http://www.onlinegamekey. com/ MTGT-Auction.php Execution Code: Code: [Select] <?php ///Setting The Date & Query Range $today = date("m/d/Y"); $minusday = mktime(0,0,0,date("m"),date("d")-14,date("Y")); $queryday = date("m/d/Y",$minusday); ///Getting The Data $quer2=mysql_query("SELECT * FROM auctions WHERE Card_Name ='$cards' AND Day >='$queryday' ORDER BY Price_Per") or die; ?> Additional Notes: My database stores the date in this format mm/dd/yyyy in column `Day` stored as a VARCHAR. Testing on the site: Search for Air Elemental this card is new today (Auction ID)543716 (Card Name)Air Elemental (Cards Per Auction)1 (Seller)Edwitdahead (Auction Price)7 (Price Per)7.00 (Date)01/01/2012 I would like to avoid changing the database format if possible, and I assume this is likely a common issue so any help pointers or links you can provide to help me fix this is Greatly Appreciated. Thank you I have a client and a server solution setup at the moment. We are currently creating an API that will be run on the clients end that will allow their clients to connect to them. On our end, we want to log the number of attempts are API is being used so that we may charge the clients appropriately. My question is this. How is the most efficient way of doing this? Do I call mysql_connect from the client and just shoot the insert log statements across the web. Should I create a php script on our end that looks for post/get input and takes the data and inserts it? What if the client can't connect to our server; should I cache the data and send it off all at once? Should I create a job that every hour shoots up x records API requests happened? Relatively confused at what angle I should be taking when approaching this. I want this to be scalable to a point where we can have thousands of requests an hour, and not horribly slow down apache/mysql running at either end (Specially if the server is talking with several clients). I have been trying to learn how to build a php/mysql website using my local computer for testing. I'm at the point now where I need to move my files over to our server so I can give an update and show how much I have done. On my computer I have been setting up my include lines like this. include $_SERVER['DOCUMENT_ROOT'] . '/includes/head.inc.php'; the problem is that when I move my files over to the server I want to put them in a .htpassword protected directory called dbsite until the new site is ready to go live at which point I will move the files out of that directory and put them in the root dir. (there is currently I live site which I am replacing with this new one in the root right now, but until I'm ready I can't delete/overwrite the current one) My question is, is there a way to make $_SERVER['DOCUMENT_ROOT'] = the dbsite dir instead of the actual root dir? Just temporarily while the site is in the testing directory on the server. Otherwise I have to change all of my lines on my local computer from include $_SERVER['DOCUMENT_ROOT'] . '/includes/head.inc.php'; to include $_SERVER['DOCUMENT_ROOT'] . '/dbsite/includes/head.inc.php'; which will then cause the files on my local computer to not work correctly. Am I making sense as to my dilemma? Is there an easier/better solution? Thanks. Hi all. I have a video upload page utilizing ffmpeg to convert to .flv format via ajax with progress bar. Currently I am having an issue where the user uploads the video however the same upload script also converts to .flv format (exec("ffmpeg -i etc..")) after the file is uploaded. This is working fine however if the user selects to move away from the page after the video is uploaded it is causing the users browser to lockup (and sometimes crash). How can I make the exec() command to convert the video format strictly run server side and allow the user to move away from the page even though the conversion is still processing? Thanks for any advise on how to handle this issue. This may be a stupid question so forgive me if it sounds like a dumb question. I have my own server set up and I was wondering if it was at all possible to have a script running that is hosted on my server, while my PC is off or possibly just without having to load it within my web browser. I have a few scripts I wish to run forever without lagging my old PC. Is there a way to do this? Thanks. P.S All the scripts will be using the file_get_contents function to open HTTP streams, and a few explode functions here and there. I'm trying to make a simple website where people register to my website. When the user doesn't fill anything inside the boxes they get a message "Please fill all required fields" on the register.php page On my local host require_once works good. It shows up.
But when i upload the files to my sever the require_once does not show up on the register.php It just refreshes and i dont get the message "Please fill all required fields"
This is the code that works in local host but not in a live server <?php require_once 'messages.php'; ?>
Here is my full code
Register page: <html> <?php require_once 'messages.php'; ?> <br><br> <form action="register-clicked.php" method="POST"> Username:<br> <input type="text" name="usernamebox" placeholder="Enter Username Here"> <br><br> Email:<br> <input type="text" name="emailbox" placeholder="Enter email here"> <br><br> Password:<br> <input type="password" name="passwordbox" placeholder="Enter password here"> <br><br> Confirm Password:<br> <input type="password" name="passwordconfirmbox" placeholder="Re-enter password here"> <br><br> <input type="submit" name="submitbox" value="Press to submit"> <br><br> </form> </html>
Register clicked <?php session_start(); $data = $_POST; if( empty($data['usernamebox']) || empty($data['emailbox']) || empty($data['passwordbox']) || empty($data['passwordconfirmbox'])) { $_SESSION['messages'][] = 'Please fill all required fields'; header('Location: register.php'); exit; } if ($data['passwordbox'] !== $data['passwordconfirmbox']) { $_SESSION['messages'][] = 'Passwords do not match'; header('Location: register.php'); exit; } $dsn = 'mysql:dbname=mydatabase;host=localhost'; $dbUser='myuser'; $dbPassword= 'password'; try{ $connection = new PDO($dsn, $dbUser, $dbPassword); } catch (PDOException $exception){ $_SESSION['messages'][] = 'Connection failed: ' . $exception->getMessage(); header('Location: register.php'); exit; }
messages.php <?php session_start(); if (empty($_SESSION['messages'])){ return; } $messages = $_SESSION['messages']; unset($_SESSION['messages']); ?> <ul> <?php foreach ($messages as $message): ?> <li><?php echo $message; ?></li> <?php endforeach; ?> </ul> Edited Wednesday at 12:49 AM by bee65 Hi, I am not a PHP programmer. I took on a new client with a simple PHP site, without any databases. The site is up and running on the web. I would like to get it running on my local machine for further development. I have latest version of WAMP installed, running Apache version 2.2.11 and PHP version 5.3.0 I created a directory in the WAMP "www" project directory and it shows up there like it's supposed to when I browse to "localhost" Problem: The home page of website displays text but no, images, styles, footer, header, nav links, etc. Here is the code for the home page: <? define("NAV","home"); require_once('local/local.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>TITLE</title> <meta name="keywords" content=""> <meta name="Description" content=""> <? include("common/dochead.php"); ?> </head> <body onLoad="<? include('common/preloads.php'); ?>"> <!-- ============================ main ============================= --> <div id="main-frame"><div id="main" class="noCollapse"> <? include("common/sign.php"); ?> <div id="right-frame"> <? include("common/navigation.php"); ?> <div id="content-frame"> <div id="content"> <h1>Welcome</h1> <p>This is the content area. This is the content area. This is the content area. </p> </div><!-- end content --> </div><!-- end content-frame --> </div><!-- end right-frame --> <div class="clearFloats"></div> </div><!-- end main --></div><!-- end main-frame --> <? include("common/footer.php"); ?> </body> </html> Any help would be greatly appreciated. I have spent many hours on this. Regards Hi folks, I'm curious if I can for example, save a file from my server and it will save to all other servers - obviously if they accepted the connection first. It's for a software I developed and is almost complete and know there will be frequent updates to it. Instead of users downloading upates, I want the update files from my server to somehow synchronize to their server automatically? Anything called this?? Thanks for info. This isn't exactly an application design question, but rather a system design one.
I am about to install an Inventory Control System inside this store I work in.
The store itself also owns a Linode VPS running Centos 6.4 which hosts our website.
This new Inventory System will come built in with a Microsoft SQL Server, and supposedly it is a SQL Anywhere database, but I'm not too sure what that means.
I need to make this database publicly accessible, but only via the Linode VPS. Surely, setting restrictions is easy enough to address that issue. That isn't my question.
My first idea is to put this server into the DMZ, easy. But it doesn't exactly sound safe. So my next idea was to put a middleman server in the DMZ, this way the Linode can send queries to that middleman server and it will send that data to the SQL Server and back. This is very vaguely described I know, but I don't want to get too much into details, but rather, understand how I can create that middleman server, and what could Install onto it that would allow me to securely process queries?
My first thought was to install a webservice, that accepts an XML/JSON request and returns an XML/JSON response.
Then, I realized directly afterwards that I don't have any experience setting up a webservice like that.
What kind of options are there out there? Ultimately, my question is, should I just put the Server in the DMZ or should I create the middleman, and if so, can someone point me in the right direction as to getting a webservice set up? Edited by Zane, 15 July 2014 - 11:28 PM. Following a tutorial on udemy, i tried to learn the very basics of mvc structure. I built the same project on my local server and it worked without giving me any error. but when i tried it on live server. its not working as it should. not showing any error. I tried to figure out the problem and found that for every page loading, it stops at the same line in my main.php file. <?php require($view); ?> starting from the above line. it stops. i came here to share my problem but i am unable to upload my files here. if there is a way to upload and share my files, please guide. zip file size of the whole project is 31.6 kb Hey. I am wanting to move a couple of files from my current server to another. If i am uploading the file this is fine but if it is already on the server then im not sure how to move it. When uploading I can just use ftp_put($conn_id, $destination_file, $myFile, FTP_BINARY); What i need to do is figure out how to get a hold of the file and store it in $myFile then this would work fine. Is this possible? Cheers (This might be the wrong forum; it might be server-side configuration, but alas it is the code that *calls* fwrite, so I'll start here.) I have written a script, and one thing it does is generate a file to disk using fwrite. No big deal. Here's what interests me: On most servers, the file is written successfully when the folder's permissions are 755 with recursive permissions. On some servers, 755 fails. Only 777 works. How could this be? Are permissions=permissions=permissions? Why will 755 work on one machine but not another? I'm just a logic guy; I know very little of server-side configuration and/or why there would be a difference here. Just trying to learn. I have two servers: WebServer and FaxServer. WebServer needs to send a fax. Is my approach shown below fairly secure? Before sending a fax, ServerWeb needs to store a record in a table representing the message, and I am using a pseudo random value for the PK which is generated as 2147483648+mt_rand(-2147483647,2147483647). WebServer then generates a hash equal to hash('sha256',$pk.'secretCodeWhichOnlyWebServerAndFaxServerKnow'). WebServer then sends curl request to FaxServer using POST which includes $pk, the hash, the fax number, some text to include in the fax, and an optional array of document to include (array(array('id'=>321,'name')=>'fileName.pdf')). FaxServer verifies that the hash is correct given $pk, that the minimum information has been received, and that the fax number is a valid phone number, and quickly responds to WebServer by echoing 0 or 1 so the code in the WebServer could continue and inform the user. If all looks okay, a new instance of PHP is started. if(missingInformation) {echo(0);} else { session_start(); $_SESSION['_xfr']=$_POST; exec('/usr/bin/php -q /path/to/send_fax.php '.session_id().' >/dev/null &'); echo(1); }New instance of PHP send_fax.php then does the following: session_id($argv[1]);//Set by parent session_start(); $data=$_SESSION['_xfr']; $doc_list=null; foreach ($data['documents'] AS $doc) { if(ctype_alnum($doc['id'])) { $file='/some/tmp/directory/'.$doc['id']; if(!file_exists($file)) { $url='http://machine.WebServer.com/index.php?task=displayDocument&id='.$doc['id'].'&x='.hash('sha256','displayDocument'.$doc['id'].'secretCodeWhichOnlyWebServerAndFaxServerKnow'); $cmd='wget -O '.$file.' '.escapeshellarg($url); exec($cmd); } $doc_list.=' '.$file; } exit('invalid document'); } //Send the fax... //Send another CURL request to the WebServer similar to the wget giving the fax status. exit;When WebServer receives the wget request for a document, it confirms the hash and sends the document to the FaxServer using X-Sendfile. When WebServer receives the CURL request regarding status, it updates the database for the applicable message. Seem reasonably secure? What I'm trying to do is copy all files from one server to another folder on another server. Here is what I have have so far.. <?PHP //connection settings $ftp_server = "server"; $ftp_user_name = "user"; $ftp_user_pass = "pass"; $dir = "/var/test/"; $destination_file = "/test/"; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; } if (ftp_chdir($conn_id, $dir)) { echo " <br/>Current directory is now: " . ftp_pwd($conn_id) . "\n<p/>"; } else { echo "Couldn't change directory\n<p/>"; } $buff = ftp_rawlist($conn_id, $dir); foreach($buff as $files) { echo $files. "<br/>"; if (ftp_get($conn_id, $destination_file."test.file", $dir."test.txt", FTP_BINARY)) { echo "<br/>Successfully written to $destination_file\n"; } else { echo "There was a problem\n"; } ?> That doesn't work. Any ideas? Thanks, Sean |