PHP - Working Local Php Project Doesn't Function On Web Server
Hi All
I have been working on a project in PHP for about three months. I have been happily working away with a WAMP server locally all that time. The problem arose today when I uploaded the project to a web server. I uploaded all the files by FTP and imported a mysql database on the new web server. When I went to view my home page I got the following error: Parse error: syntax error, unexpected T_STRING in /home/priestbr/public_html/output_fns.php on line 1 My index page references an include to a page which stores my functions: <?php error_reporting(E_ALL ^ E_NOTICE); session_start(); include('priest_br_fns.php'); The priest_br_fns.php then includes a further 3 includes as below: <?php include_once('db_fns.php'); include_once('output_fns.php'); include_once('general_fns.php'); ?> PHP seems to parse the db_fns.php page OK and fails at output_fns.php (as per the parse error msg). But here's the thing....during some investigation I deleted the contents of db_fns.php and pasted in the contents of output_fns.php and then the page got parsed OK! Anyone have any idea why it's failing? Is it something to do with how I have the includes set up? I really need all the includes working obviously for the site to run. For info my local server where the site works perfectly is set up as below: PHP 5.2.6, MySQL 5.0.51a, Apache 2.2.8 The web server is set up like this: PHP 5.2.1.14, MySQL 5.0.91, Apache 2.2.16. Thanks in advance, Craig Similar TutorialsFollowing 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 I just did a huge import from an app I have been working on. No issues except for this. I uploaded & imported all files & databases from my wampserver (localhost, local server) to my main online server. Before I continue with the problem, I have to give you info on how the files work. I am using a "controller" to view the files. Meaning, from index.php, I call all the files. For example, instead of mysite.com/register.php, its mysite.com/index.php?page=register. The index defines the doctype & html tags etc. The other files that are called through index.php are just pure php code, it does not contain the head & body tags etc. So, the issue is , when the surfer submits a form, i need to set a cookie. this cookie is VERY important. I cannot get it to work. I am getting the header warnings after submit Of course, this is to be expected. But I tried it on my local server, & it worked. I am not very familiar with cookies, this is a side of PHP i never really even touched. I know almost everything but that. So the php code is before the html code on the page, so I figured it was worth a shot. Im guessing the problem here is, since the code being outputted as index.php code + the form page code. So the cookie is being set after the html tags. How can I fix this? I need it to work thru the controller. I cannot just make it a single file, all files on the site needs to be thru this controller, otherwise it will mess everything up. Ino I could just add the code from index.php plus the form page code & just run the php code before all of the html tags, but like I said it has to be called thru index.php. I appreciate your replies, & I hope you guys dont think im an idiot & can understand my question, im terrible with words! Hello, I have a call tu function unserialize() in a script that receives a string and has to return an array. In my localhost it works properly but in the server it returns a 1 dimension array with empty value. I'm testing with the string a:1:{s:1:"0";s:8:"value_eq";} The php.ini configuration for magic_quotes is (in both, server and localhost): magic_quotes_gpc Off magic_quotes_runtime Off Other configurations is difficult to compare, as php info is long and very different in local and server. Any ideas where the problem might be? Thank you 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 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 Guys,
I'm actually a .net programmer, but was asked by a local company to make some improvements / add new features to an internal web app they use to help them manage their project pipeline.
I've been working with them for about a year and learning PHP as I go along. The site was originally built in house by a keen programming hobbyist so between him and me the code is probably a bit non-standard.
I'm looking for an experienced PHPer (with the usual web dev addons: JS/JQuery, CSS, HTML, MYSQL) who would be interested in putting in some hours/days to help move the thing along and happy to pay £150/day or equivalent hours if preferred.
The project is in a Git Repository on Kiln (owned by FogCreek, who do Fogbugz if you've heard of that) but I could move it to GitHub no probs. Current dev site is hosted on Vidahost.
Thanks,
Fergus
Hi ppl I have a weird error... (or at least i think its weird) I have a project with 3 forms, and at the end(the last file) will enter all data of this form in an email and sent it using PEAR smtp email. On my local server it works. Everything - from testing all the mandatory fields in each form till the sending of the email. I also receive the email using @localhost. When I upload these files to the server, every form with the testing of the mandatory fields and returning to that form, everything works, except the file where I test the last form and put all content in the email body. On the server, as soon as the last page starts to load, I get a Server Error HTTP Error 500. I really don't understand it, as everything works on my local xampp server. Please let me know of places I can search for errors... like log files on the server or something like that. Thanks PS: I also used NetBeans, with its debugger, so I am quite sure its not the code, maybe a php setting... im wondering is there any easy way to echo server time and local time... without converting them from unix to timestamp i have found thi code, but i cant tell is it server or local Code: [Select] echo date("H:i" ,time()); Hey! I'm trying to use a local server to test my site out. I'm using dreamweaver for all the coding. I installed WAMP server and have the local host working. When I preview the site, it really is messed up. For example, if I have this code: Code: [Select] <? /** * Main.php * * This is an example of the main page of a website. Here * users will be able to login. However, like on most sites * the login form doesn't just have to be on the main page, * but re-appear on subsequent pages, depending on whether * the user has logged in or not. * * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC) * Last Updated: August 26, 2004 */ include("include/session.php"); ?> <table> <tr><td> <? /** * User has already logged in, so display relavent links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] " ."[<a href=\"useredit.php\">Edit Account</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center</a>] "; } echo "[<a href=\"process.php\">Logout</a>]"; } else{ ?> <h3>Login</h3> <? /** * User not logged in, display the login form. * If user has already tried to login, but errors were * found, display the total number of errors. * If errors occurred, they will be displayed. */ if($form->num_errors > 0){ echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>"; } ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>> <font size="2">Remember me next time <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> <? } /** * Just a little page footer, tells how many registered members * there are, how many users currently logged in and viewing site, * and how many guests viewing site. Active users are displayed, * with link to their user information. */ echo "</td></tr><tr><td align=\"center\"><br><br>"; echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>"; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.<br><br>"; include("include/view_active.php"); ?> </td></tr> </table> I get this: Code: [Select] logged_in){ echo " Logged In "; echo "Welcome $session->username, you are logged in. " ."[username\">My Account] " ."[Edit Account] "; if($session->isAdmin()){ echo "[Admin Center] "; } echo "[Logout]"; } else{ ?> Login num_errors > 0){ echo "".$form->num_errors." error(s) found"; } ?> Username: "> error("user"); ?> Password: "> error("pass"); ?> value("remember") != ""){ echo "checked"; } ?>> Remember me next time [Forgot Password?] Not registered? Sign-Up! "; echo "Member Total: ".$database->getNumMembers()." "; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site. "; include("include/view_active.php"); ?> To me, it seems like a " problem but I don't see why it would be happening. Hi all, I have two issue with script. 1. It works in PhpEd and with apache but doesn't work at remote server with apache. Error is well known - "Warning: Cannot modify header information - headers already sent " 2. when I added more than 20 records like $var = $_POST['var']; it stops work local. Error is same. adminka_wrapp.php Code: [Select] <?php $addFormatName = $_POST['addFormatName']; $addFormatDes = $_POST['addFormatDes']; $page = $_GET['page']; if (isset($addFormatName) && isset($addFormatDes)) { $page = 'add_formats'; } else if ($page == NULL) { $page = "user_access_log"; } ?> <!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> <link rel="stylesheet" type="text/css" href="../style/adminkaview.css"> </head> <body> <div class="col-wrap1"> <div class="col-wrap2"> <div class="col1"> <div class="content" id="c1"> <p><a href="?page=view_add_format">Format and extensions</a></p> </div> </div> <div class="col2"> <div class="content" id="c2"> <?php require("$page.php");?> </div> </div> <div class="clear"></div> </div> </div> </body> </html> view_add_format.php Code: [Select] <?php require_once "../function.php"; $q = connect("SELECT `formats`.* FROM `xxx`.`formats` "); echo "<form method='post' action='adminka_wrapp.php'> <table> <tr> <td>id</td> <td>Formats Name</td> <td>Description</td> </tr>"; while($rowResult = $q->fetch_assoc()) { echo "<tr>"; $id = $rowResult["id"]; $formatName = $rowResult["f_name"]; $description = $rowResult["description"]; echo "<td>".$id."</td>" ."<td>".$formatName."</td>" ."<td>".$description."</td>"; echo "</tr>"; } echo " <tr> <td> <input type='submit' value='AddFormat' name='submitAddFormat'> </td> <td> <input type='text' name='addFormatName' maxlength='20' size='5'> </td> <td> <input type='text' name='addFormatDes' maxlength='20' size='5'> </td> "; echo "</table> </form>"; ?> add_formats.php Code: [Select] <?php require "../function.php"; if (isset($addFormatName) && isset($addFormatDes) ) { $q = connect("INSERT INTO `xxx`.`formats` (`id` ,`f_name` ,`description` ) VALUE (NULL ,'$addFormatName' ,'$addFormatDes' ) "); header("Location: adminka_wrapp.php?page=view_add_format"); exit(); } ?> function.php Code: [Select] <?php function connect($query) { $db = new mysqli('127.0.0.1', 'xxx', 'xxx', 'xxx'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $result = $db->query($query); $db->close(); return $result; } ?> Hi, ive recently created a gallery website and im happy with the way everything currently works. However the main drawback is the site uploads using a html webfom which is great for remote users or the odd image. However, as i want to mass upload my existing collection i will need the ability to read a selected folder and then to carry out all the same processes that existed from the existing html form upload. Im also using gdlibrary and checking file types to ensure they are within my allowed list, but im wondering if there are any other common security alerts i should be aware of to keep things a little bit safer if/when i publish outside of my LAN. So in a nut shell i need some assistance with changing my upload process to work for more than one file at a time, ideally by reading a folder, or at least reading X amount of files at a time - processing them then moving onto next batch of files in the list. Then the next part i need help with is checking/improving basic security of the system I have been working on a blog program with a tag system. When I add tags and ask to display them to a certain webpage they all appear on my WAMP environment but not my live server. Any thoughts as to why this might be? Here is the code needed to display the tags. I am not sure if maybe live servers have restrictions that might be stopping it from displaying.
This is on the main page to display the tags.
<div class="widget"> <?php echo '<h2>Tags</h2>'; echo '<ul>'; getTagCount($DBH); echo '</ul>'; ?> </div>Next here is the function from the includes file. function getTagCount($DBH) { //Make the connection and grab all the tag's TAG TABLE HAS TWO FIELDS id and name $stmt = $DBH->query("SELECT * FROM tags"); $stmt->execute(); $result = array(); $result = $stmt->fetchAll(); //For each row pulled do the following foreach ($result as $row){ //set the tagId and tagName to the id and name fields from the tags table $tagId = $row['id']; $tagName = ucfirst($row['name']); //Next grab the list of used tags BLOG_POST_TAGS TABLE HAS TWO FILEDS blog_post_id and tag_id $stmt2 = $DBH->query("SELECT count(*) FROM blog_post_tags WHERE tag_id = " . $tagId); $stmt2->execute(); $tagCount = $stmt2->fetchColumn(); //Print the following list echo '<li><a href="blog_tags.php?tagId=' . $tagId . '"title="' . $tagName . '">' . $tagName . '(' . $tagCount . ')</a></li></form>'; //End of loop - start again } }The "tags" database is structured like so id, name The "blog_post_tags" is structured like so, blog_post_id, tag_id On the WAMP server it returns all of tags while the live server only returns the first one. Any suggestions on what is going on? If you need any other info please let me know. hello and good day dear php-freaks which is the passwd for the mysql db run opensuse - therein i have installed a myql serfver and an apache now i want to port over a cms-system from a server to the localhost. question: the passwd of the configuriatin of the cms has got the following db connecgtion host : localhost db-name db-passwd question: does the db passwd need to match the passwd of the local mysql server!? is this true love to hear from you Hi, I have a mail script to that will take a long time to process, let me call it form2.php Now I post from form1.php to form2.php. I like to run/execute the form2.php in the background so that the user will not wait for the time executing the form2.php. I have used exec and shell_exec but not success. I am using latest WAMP server in my local mechine. Thanks Hi all, Hi there, Can anybody help me to write php/javascript code which will allow users to open files directly from web browser into desktop application? Here is the specification: I have a photo editing business with many people working in Photoshop. I am currently developing a web based application (joblist) using Javascript and PHP which should allow the photoshop designers to browse and open files/images directly from joblist/web browser into photoshop. The reason I want this instead of browsing folder is that I have a database where I store who worked on which file, when and how long it took. The concept is that, designers will select a file and click on start, as soon as they click on start the original file will open in Photoshop and there will be an entry into database (using PHP). Once they finish the task they will close the file and click on Finish button. My joblist application will be published in a local server and the file will be open on a local network, so when they save the file it will be saved where the source file is located in (local server). The application should work in both PC and Mac. I have already done all other part of the application except file opening directly from browser to desktop application functionality. Anybody can help me to write the code (PHP or Javascript) which can open the file from browser (local server) directly into desktop application e.g. PHotoshop or Illustrator? Thank you very much I look forward to someone's real help! Best regards Mr. Sumon Hello Everyone, I am on windows server and In my ini file server time zone declared as below
[server_settings] but my application installed on another timezone eg: 'America/Los_Angeles' time zone. using date_default_timezone_get() i am always getting Europe/London timezone as it's declared in ini file. How to get local timezone(wherever application is installed) here? Thanks Krish $account="54646456456464"; $station= "12345"; $options="11-1"; $image="C:/Desktop/Sample Images/usco1.jpg"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://dfdgfsfs.com/kgdfgd.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => '@'.$image, 'account' => $account, 'station' => $station, 'options' => $options)); $postResult = curl_exec($ch); curl_close ($ch); $xmlobj = simplexml_load_string($postResult); echo (string)$xmlobj->ID->attributes()->value; echo (string)$xmlobj->FullName->attributes()->value;All, I have spend days trying to figure this out without any luck. I am now in crisis mode. I need to get this working asap. The following code works perfect on my local xampp machine. As soon as I upload it to my web server, I don't get any data back. I have narrowed it down to the image i am trying to send is not being received properly. Thanks in advance. Hi guys, I need a help to find out what is a problem. Some of my code does not work on my local comp and in the same time it works well when I place it on Internet server. First example: Code: [Select] <body> <?php if($_POST['submit_form'] == "Submit") { $varNewTeam = $_POST['Reg_Team']; $varNewCity = $_POST['Reg_City']; $db = mysql_connect('localhost', 'root', '') or die ('no connection with server'); mysql_select_db('db_m ,$db) or die('DB error'); mysql_query ("INSERT INTO reg2012 VALUES ('$varNewTeam','$varNewCity')") or die('insert error'); } ?> <form action="registration_2012_form.php" method="post"> <p>Team: <input type="text" name="Reg_Team" size="20" maxlength="50" value="<?=$varNewTeam;?>" /><br /></p> <p>City: <input type="text" name="Reg_City" size="20" maxlength="50" value="<?=$varNewCity;?>" /><br /></p> <p><input type="Submit" value="Submit" name="submit_form" /></p> </form> </body> On local comp: It gives me message "Undefined index: submit_form". On Net server works well. If I split the code in two files. In the first one I leave the form with "action=FILE2.php" and put my php code in the second file "FILE2.php" - it starts work even on local server. second example: Code: [Select] <body> <?php $db = mysql_connect('localhost', 'root', '') or die ('no connection with server'); mysql_select_db('db_m' ,$db) or die('DB error'); mysql_query ("CREATE TABLE temp1 (team char(50), city char(50) )") or die('create tables error'); ?> </body> It works in the Net and can not create the TABLE on my local comp. I use XAMPP on my local comp (if it's important) |