PHP - Stoped Working After New Host
Hi all,
I have a small script I found somewhere but after I changed hosting, it just stop to work. I just want to record the user IP and Referrer etc. in a .txt file using fopen. It helps to see what users searched for in search engine etc. The headers are there but no data... Please help?? session_start(); if($session["logged"] != "yes") { $agent = $_SERVER['HTTP_USER_AGENT']; $uri = $_SERVER['REUEST_URI']; $ip = $_SERVER['REMOTE_ADDR']; $ref = $_SERVER['HTTP_REFERER']; $visitTime = date("r"); $logLine = "$visitTime - IP: $ip || User Agent: $agent || Page: $uri || Refererrer: $ref\n\n"; $fp = fopen("indexLog.txt", "a"); fputs($fp, $logLine); fclose($fp); $_SESSION["logged"] = "yes"; } ?> Thanx in advance Jaco Similar TutorialsI changed web hosting companies and now a php form that was working is no longer working. I haven't been able to figure out what the problem is. The form is a simple text input form that adds the text to a database. Every time the user inserts text with a comma, an error occurs. Below is the code for the form. Any help is much appreciated. I am creating a news updates thing for my website and i have managed to get it working on my home PC (im using XAMPP) but when i upload to my webhost it doesnt appear to work. I am wondering if it is just my host or whether i have done something wrong and by chance it works on my home PC. Here is my code: <?php include("includes.php"); doConnect(); $get_news = "SELECT title, text, DATE_FORMAT(datetime, '%e %b %Y at %T') AS datetime FROM newsfeed ORDER BY datetime DESC"; $result= mysqli_query($mysqli, $get_news) or die(mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { echo '<strong>'. $row['title'] .' </strong><br>'. $row['text'] .'<br>'. $row['datetime'] .'<br><br>';} ?> My includes file is: <?php function doConnect() { global $mysqli; //connect to server and select database $mysqli = mysqli_connect("localhost", "user", "password", "dbname"); //if connection fails, stop script execution if (mysqli_connect_errno()) { printf("Connection failed: %s\n", mysqli_connect_error()); exit(); } } ?> I think im right in saying it connects properly because i do not see an error. what i get is: Code: [Select] '. $row['title'] .' '. $row['text'] .' '. $row['datetime'] .' ';} ?> Im new to PHP (incase you hadnt guessed!) so not really sure whats happening. On my home PC i have PHP Version 5.3.1 and on my webhost its 5.2.14. Home PC mySQL version 5.1.41 and on webhost its 5.0.91-community. Could this be the reason? Thanks I currently have a list of host addresses. I need to get the mx records for them. I was looking at the documentation, and found the getmxrr(). Would that send back the mx record, or just true if it has one? Hi, I just realised that date() function depends on where ever your hosting company is from. Is there any way to change this manually as I am from UK and the day changes early compared to where my hosting company is (USA). The reason I want to know this because I have some functions where the user should only be allowed to choose the current date which I want to be according to GMT time. Any help is much appreciated thanks in advance! Hi, i have this code Code: [Select] print get_domain("http://www.somedomain.com"); function get_domain($url) { $pieces = parse_url($url); $domain = isset($pieces['host']) ? $pieces['host'] : ''; if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) { return $regs['domain']; } return false; } mysql_query("INSERT INTO table VALUES('', '$domain')"); And i want to check that the www.somedomain.com is not an ipaddress or localhost (i.e. localhost, 127.*.*.*, - Local 192.168.*.* -LAN or *.*.*.* (as an ip) - Actual IP Any help would be much appreciated thanks, jack HI, My host support pop protocol. I want my host to receive emails and do some process on it with php coding and then store then.But I don't know how to receive emails using my host and how can I have access to them to do some process on it. How can I do that? Thanks Hey.. hoping someone can help me on a this issue I have been having for 4 days now. My host has tried to figure out what is causing it and has told me they are finding it very strange, everytime my website is up on their server it will take 600%-800% CPU so they must take it down for fair usage on other customers of course. They said they can easily track and trace websites that are overloading the resources but mine seems too complicated to understand as it is having legitmate traffic (on average 30 users online and 300 visits daily) which would never be the cause of CPU spikes to 600%-800%. They either believe it is a "clever attack" or some PHP script perhaps looping like mad. Anyone help me and my host figure out the problem as we obviously both don't like the website to continue to be offline. The website has very standard content CMS running and clean database it makes no sense to the both of us. Like to mention the last activity I had done on the website was when I tried to insert into database:- Code: [Select] Query failed: errorno=126 error=Incorrect key file for table './teamxcom_webspell/ws_bi2_cup_matches.MYI'; try to repair it query=DELETE FROM ws_bi2_cup_matches WHERE matchno='5' && type='gs' && ladID='0' && 1on1='1' Then after I tried to perform query from database: Code: [Select] Error SQL query: SELECT * FROM `ws_bi2_cup_matches` ORDER BY `ws_bi2_cup_matches`.`matchID` DESC LIMIT 0 , 30 MySQL said: #1030 - Got error 134 from storage engine Then found out the table on phpmyadmin had wrong page numbers in sequence:- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 379, 746, 1113, --, --, --7349 After I contacted web host they mentioned it is causinga massive problem and took it down after that. Anyone can shed some light on this please? Sorry if it is posted in wrong section! Thanks very much I launched my new website about a month ago. I switched from one web host to another due to poor hosting performance. Now I'm running into the same issue again -- poor web hosting performance.
My first web host was Hostgator. My current web host is AT&T. I hate the thought of switching to a different web host every month trying to find one that will reliably host my site. Does anyone here have a reliable web host that they use and would recommend?
My question is relative since what is reliable for a simple web site, may not be reliable for one that is more complex. For this reason, I can't simply trust web host reviews.
My website isn't overly complicated, but it's more complex than just basic HTML. It uses a lot of PHP, as well as a MySQL database that only has two small tables. The website uploads and downloads small text files regularly. It also sends E-mail attatchments quite often.
Because I just launched, my website isn't getting a ton of traffic -- about 10 users per day. However, I'm beginning to run into the same problem as before. My web host's server is starting to show itself as being unreliable. As with my first web host, it seems as if it may be due to overcrowding on the shared server.
Do any of you run any moderately complex websites? If so, who do you use for a reliable web host?
I've considered setting up my own server with a LAMP configuration and hosting the site myself. However, I don't know a lot about Linux or Apache, and so would like to avoid this. But because the computer would only be hosting my own website, and no one else's, I have to believe that a LAMP setup would be more reliable than a shared server that is overcrowded.
A reliable web host is really what I'm looking for. But I don't want to keep going down the road of trial and error. If anyone uses a web host that reliably supports their moderately-complex website, then I would love to hear from you. I'm sick of my site failing due to server issues. Like the Duracel commercial says, "It just has to work!"
Please forgive me if you feel that my post doesn't correctly fit the forum category. I tried to figure out which category best fits this topic, but none of them seemed to be perfectly suitable.
Thank you for your time, as well as for any suggestions.
Help me!!
Seem when i run the scripts, the output seems wrong
This is the output...
The 1st and 3rd entry is true, online
But the rest should be OFFLINE but the output shows all ONLINE
I think the problem is from foreach loop but I cannot figure out how to solve the problem
Please help me...
<?php include 'connector/connect.php'; ?> <meta http-equiv="refresh" content="6" > <style> tbody > tr:nth-child(2n+1) > td, tbody > tr:nth-child(2n+1) > th { background-color: #ededed; } table{ width: 70%; margin: auto; border-collapse: collapse; box-shadow: darkgrey 3px; } thead tr { background-color: #36c2ff; } </style> <h1 align="center">Server Availability</h1> <table border="1"> <thead> <tr> <th>Entry</th> <th>Host</th> <th>Name</th> <th>Location</th> <th>Description</th> <th>Availability</th> </tr> </thead> <tbody> <?php $sql = "SELECT * FROM host_entry"; $no = 1; $dbhi = $dbh->query($sql); foreach ($dbhi->fetchAll(PDO::FETCH_BOTH) as $data) { ?> <tr> <td><?php echo $no++; ?></td> <td><?php echo $data['host_server']; ?></td> <td><?php echo $data['host_name']; ?></td> <td><?php echo $data['host_location']; ?></td> <td><?php echo $data['host_desc']; ?></td> <td> <?php $ip = $data["host_server"]; // Run the ping to the IP exec ("ping -n 1 -w 1 $ip", $ping_output); if(preg_match("/Reply/i", $ping_output[2])) { echo "<font color='green'><strong>Online!</strong></font>"; }else{ echo "<font color='red'><strong>Offline!</strong></font>"; } ?> </td> </tr> <?php } ?> </tbody> </table> $download will print on the screen on my localhost, but once I've uploaded it to my host and go to the website, everything else prints to the screen fine, but $download will not. When I view page source, shows nothing where $download should be. $link_pattern = "/<tr><td><a(.*)<\/tr>/sU"; preg_match_all($link_pattern,$cr,$dm); $downloads = $dm[0][0]; $pattern = '/src=\"/'; $replacement = 'src="http://www.triplestarent.com/images'; $download = preg_replace($pattern, $replacement, $downloads); ?> <div class ="container"> <br> <h1> <?php echo $title; ?> </h1> <br> <?php echo $image; ?> <br><br> <h2> Track List </h2> <?php echo $tracks; ?> <br><br> <h2> Download </h2> <br> <table> <?php echo $download; ?> </table> <br><br> </div> My web host wont turn on Curl.dll is there any other way to do this with out using Curl #---------------------------------------------------------------------------- # Curl code to store XML data from PWA in a variable #---------------------------------------------------------------------------- $ch = curl_init(); $timeout = 0; // set to zero for no timeout curl_setopt($ch, CURLOPT_URL, $file); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: AuthSub token="' . $GDATA_TOKEN . '"' )); $addressData = curl_exec($ch); curl_close($ch); I am on a shared hosting server running CentOS. I have copied a PHP extension (imagick.so) that was built on similar server to my shared hosting server. I have resolved most of the dependencies by placing the missing files in ~/lib but I have one that I can't figure out how to cope with. I am getting the following error: I am using the free web host http://www.byethost2.com/ and need help figuring out where and how to make my php files to?! Currently I have the following Config file... Code: [Select] <?php // Build Date: 2011-12-17 1:15pm // Website Environment define('ENVIRONMENT', 'development'); //define('ENVIRONMENT', 'production'); // Web Root (aka Document Root) (**Physical Location) define('WEB_ROOT', ENVIRONMENT === 'development' ? '/Users/user1/Documents/DEV/++htdocs/05_Debbie/' : '/var/www/vhosts/MySite.com/httpdocs/'); // Base URL (**Virtual Location) define('BASE_URL', ENVIRONMENT === 'development' ? 'http://local.debbie/' : 'http://www.MySite.com/'); ?> What am I supposed to use for WEB_ROOT and BASE_URL on this free hosting site?! Currently, to view my test website you go to... http://www.doubledee.byethost2.com/ I suppose that could be "BASE_URL", but for where things are physically stored so I can redefine "WEB_ROOT" I have no clue... Help! Thanks, Debbie HI all, this is a strange request so bear with me. I have setup a server on my local machine, what I want to do is scrape info off the real server out on the internet in some of the pages. I have that working using curl for different domains, but the issue is I have a 127.0.0.1 host entry for the domain in question because the local server name has to match the real server name for the application to run. I can get the real IP using a shell ie: echo exec('nslookup example.com 1.1.1.1'); but I don't know how to get curl to use that IP or force curl to use a different name server, any ideas?
CURL code:
thanks in advance!!
$url = "http://example.com/index.php"; $fields = [ 'id' => '1234' ]; $fields_string = http_build_query($fields); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, true); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); echo $result;
I recently switched hosts to DreamHost, and even after a completely clean install of Codesort I'm getting these errors:
The top of the Codesort admin panel:
Deprecated: Assigning the return value of new by reference is deprecated in /home/fatedus/fatedus/loved/codesort/functions.php on line 35 WARNING: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/fatedus/fatedus/loved/codesort/functions.php:35) WARNING: Cannot modify header information - headers already sent by (output started at /home/fatedus/fatedus/loved/codesort/functions.php:35)And displayed on the codes page of my fanlistings is this, too: Deprecated: Assigning the return value of new by reference is deprecated in /home/fatedus/fatedus/loved/codesort/functions.php on line 35This is line 35 of the functions.php file: $instance =& new $object;Here is a link to the script for those unfamiliar with it: http://fanupdate.net/codesort.php Here's a link to one of my fanlisting pages where the error shows up: http://odin.fated.us/codes.php Also here is a screenshot of what the error looks like inside the Codesort admin panel: http://i.imgur.com/yDlT8d9.png Help would be really appreciated, this host move has been such a pain. ;c Hi, I have a question. Can I actually use windows hosting on .php files, or .php files are only suitable to linux domain? Currently I am practicing some php files in the windows domain and I have received a message stated 'no database selected'. However I have definitely created the database, are there any other reasons which may cause this problem? Thanks <?php echo '<select name="race" id="race"> <option value="">--Please select one--</option>'; $dbc = mysql_connect(111', '111', '111', '111') or die(mysql_error()); $query = ("SELECT * FROM race ORDER BY race_id ASC"); $sql = mysql_query($query, $dbc) or die(mysql_error()); while($data = mysql_fetch_array($sql)) { echo'<option value="'.$data['race_id'].'">'.$data['race_name'].'</option>'; } echo '</select><br/>'; mysql_close($dbc); ?> This works fine on localhost, but the same code just won't update my live website cookie. Here's the code: index.php Code: [Select] $lg->updateCookies($username, $hashSalt[0]); updateCookies function: Code: [Select] $site = '.ciadacapa.com.br'; // --------------------------------------------------- // Updates the cookies // --------------------------------------------------- function updateCookies($username, $hash){ setcookie('ciadacapaUser', '', time()-3600, '/', $this->site); setcookie('ciadacapaHash', '', time()-3600, '/', $this->site); setcookie('ciadacapaUser', $username, time()+3600*24*7, '/', $this->site); setcookie('ciadacapaHash', $hash, time()+3600*24*7, '/', $this->site); return true; } Although the class is receiving the correct values, the cookie just retains the old value it had and never updates. Any ideas on this? Thanks in advance! Hi guys I found a nice script that removes all the work of writing individual embedding for a long list of video host, it works well and pretty easy to be tweaked even by non coders such as me. One problem seems to be that some host have that annoying autostart or autoplay feature when a person places a link to a forum. So if you have a forum page with multiple urls for videos that auto start or play feature drives you nuts. I have tried to tweak the code by adding a param name= and used the 0 token and the false alpha word, still no luck with vimeo, it continues to start as soon as it finishes loading. This code block shows the script file for vimeo, there are only two files in my includes to run this script so both must be tweaked with the changes, I use the nifty free PSPad editor to do this and have no trouble making any changes needed. My question is at what level can an option like disabling a feature take place, is this something that must be performed by the host or can this script actually take a param name= to disable it. Thanks for any input or advice, pointing to a good read is most welcome also. Code: [Select] if (($vimeo) && (strpos($message, 'www.vimeo.com/') !== false)){ $message = preg_replace('#<a class="postlink" href="http:\/\/www.vimeo.com\/(.*?)">(.*?)<\/a>#U', '<object type="application/x-shockwave-flash" style="width:400px;height:230px;" data="http://vimeo.com/moogaloop.swf?clip_id=$1&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=$1&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /></object>', $message);} I have a bit of code (maybe a lot, i dunno) that works pretty well. However, Im having some issues. Im using file_get_contents() to get a remote page from another server, and then displaying it on the current page. The issue? the images/css/urls are relative to the other domain, and so they don't display. I know httrack uses something like this, but it doesn't show the webpage on the server, it downloads the page. my thoughts are that if i could use some php function to change all urls to not be relative, it would work, but i cant do that. anyway, here is my code, you can try it for yourself too, if you want to to see what i mean. tryit: http://dageek247.tk/viewit/ code: <html> <head> <style type="text/css"> .perc {width:93%; height:90%;} .perk {width:6%; height:90%;} </style> </head> <?PHP if ($_GET['url'] == "") { $url = 'http://dageek247.tk/wordpress/'; } else { $url = $_GET['url']; } ?> <body> <div style="height:25px;width:100%;"> <div id="floatbar" style="background:lightblue; width:100%; height:25px; position:fixed; left:0;top:0; z-index:10;"> <center> <form method='get' action='index.php'> <input type='url' name='url' value='<?PHP echo $url; ?>' class='perc'> <input type='submit' value='Go!' class='perk'> </form> </center> </div> </div> <div id='showview' style='width:100%; height:100%;'> <?php //download the webpage $contents = file_get_contents($url); /* //mess around with the webpages code $contints = explode("\n", $contents); //go through each line and cahnge src and href code foreach( $contints as $key => $value){ //images $eqsrc = "src=\""; $src = strpos($original, $eqsrc); $src_end = $src + strlen($eqsrc); $new_src = substr_replace($value, $eqsrc & $url, $src_end, 0); //links $eqhref = "href=\""; $href = strpos($original, $eqhref); $href_end = $href + strlen($eqhref); $new_href = substr_replace($value, $eqhref & $url, $href_end, 0); } $contents = implode("\n", $contints); */ //attempt to be able to download images this way $_SERVER['HTTP_HOST'] = $url; //fails :( //view the webpage echo $contents; ?> </div> </body> </html> You can also see how i have tried to change relative urls into absolute ones in the commented out area. it doesnt work. Hi all i was wondering if someone knows a way to make sure an image which is uploaded isn't infected by a virus. I have read about avclam, but if your on a shared host your mostly not allowed to add own software. Isn't there maybe a php trick to resize the image which would magically remove a virus? If anyone knows a nice way or tricks to limit the virus breating space to a certain folder please let me know. |