HuggieBear
Members-
Posts
1,899 -
Joined
-
Last visited
Everything posted by HuggieBear
-
Use mysql_num_rows() on the results resource you get from mysql_query() Regards Rich
-
From within PHP or not? Regards Rich
-
[SOLVED] Are server specific settings hampering me?
HuggieBear replied to HuggieBear's topic in PHP Coding Help
This can be ignored now. It was down to the underlying XML Library that PHP was using to parse the file. It was obviously encountering something it didn't like. The solution was to parse every character using ord() to return the ASCII value. -
Morning all, I have a 3rd Party script that parses XML data feeds. I have a 6MB feed that I'm trying to parse and I'm having problems. When I run the script on a local WAMP server it works fine, but when I put it on my remote server it doesn't complete. It gets half way through parsing the file and just stops. Despite setting error_reporting(E_ALL); PHP doesn't report any errors. Are there any other settings that might be causing this to not complete on the remote server? The file is being read using fopen() and fread($file, 2048) Regards Rich
-
Yeah, the 45 second wait between writing this to the database: logProgress('INFO', "Getting feed from {$feed['merchant']}"); and then writing this to the database: logProgress('INFO', "Feed written to $filename"); This is where I retreive a remote file and write it locally ready to be parsed at a later date. It's the second write that's causing the error. Regards Rich
-
Evening, I'm getting an error stating that 'MySQL server has gone away'. I'm using MySQL 5.0.67 and I'm only executing a very small query. I've checked out the possible causes at the MySQL Website but I can't make much sense of it. The tables that I'm dealing with are small and don't have much data in. The data I'm inserting is very small too. <?php // Connect to the server $db = mysql_connect('server', 'username', 'password'); if (!$db) { die('Could not connect: ' . mysql_error()); } // Select the database $active_db = mysql_select_db('my_database', $db); if (!$active_db) { die("Could not use $database : " . mysql_error()); } // Query the database for all out of date feeds (table contains 13 rows) $sql = "SELECT merchant, feed_url, feed_filename FROM cp_feeds WHERE unix_timestamp(now()) - unix_timestamp(last_collected) > 86400"; if (!$results = mysql_query($sql, $db)){ die ("Unable to execute query: $sql" . mysql_error()); } // Update all out of date feeds $ood_feeds = mysql_num_rows($results); logProgress('INFO ', "$ood_feeds feeds require updating"); if ($ood_feeds > 0){ // Prepare the filepath $file_path = '/home/path/private/'; // Retrieve each feed and store it locally while ($feed = mysql_fetch_array($results, MYSQL_ASSOC)){ logProgress('INFO', "Getting feed from {$feed['merchant']}"); $contents = file_get_contents($feed['feed_url']); $filename = $file_path . $feed['feed_filename']; if (!file_put_contents($filename, $contents)){ logProgress('WARN', "Unable to write $filename"); } else { logProgress('INFO', "Feed written to $filename"); // Updates a single row in the 13 row table $sql = "UPDATE cp_feeds SET last_collected = now() WHERE merchant = '{$feed['merchant']}'"; $result = mysql_query($sql, $db); } } logProgress('INFO', 'All feeds updated'); } // Log the progress of the script function logProgress ($level, $message){ global $db; // Log table currently contains about 70 rows $sql = "INSERT INTO cp_log VALUES (now(), '$level', '$message')"; if (!mysql_query($sql, $db)){ die("Unable to insert logging info into the database: " . mysql_error()); } if ($level == "FATAL"){ die("A fatal error occured, check log for details"); } } ?> It's the inserting of log info that's failing. Incidentally, I've changed the script so that it only gets one file now. It's about 5MB and takes around 45 seconds. Is it this gap that's causing the error? The log table info is: CREATE TABLE `cp_log` ( `msg_time` datetime NOT NULL, `msg_level` varchar(6) NOT NULL, `msg` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 Thanks Rich
-
Please help - Write To SQL Within While Statement
HuggieBear replied to - - NC - -'s topic in PHP Coding Help
Are you also able to provide the structure of the two database tables? That would help too. Regards Rich -
Warning: mysql_query() in php function after move to php / mysql 5
HuggieBear replied to kev@num's topic in PHP Coding Help
Where is $hostname_kevlabels, $username_kevlabels etc. coming from? Are you setting these values in the script or getting them from a form/querystring of some kind? Quite often problems with server moves are related to a difference in the 'Register Globals' settings between servers. Regards Huggie -
Give this link a try: http://www.websitescreenshots.com/ Regards Huggie
-
I'd advise against this, if your database is designed well with indexes in the right place then there shouldn't be any need to go this route. Regards Huggie
-
This should answer the first part of your post... <?php // If statement to make sure the search criteria isn't empty if (empty($searchitem)) { // Error message goes here } // SQL query to run $sql = "SELECT * FROM table WHERE column LIKE '%" . $searchitem . "%'"; $result = mysql_query($sql) or die ("Can't execute query:" . mysql_error()); // Make sure there were rows returned if (mysql_num_rows($result) == 0) { // Error message here } else { // List found data here } ?> As for the second part, you just need to retrieve the unique ID from the database and use that to link through to your edit page (via $_GET). Regards Huggie
-
d.shankar, there's no need to take offense to what I said, I just interpreted what you said as laziness because you couldn'e be bothered to read it yourself. That obviously wasn't the case, you just worded your question badly. In a later post you made the following comment... Wouldn't the original post have been better if you'd said this then? "I've been through the whole site thoroughly and I didnt find any terms regarding usage. Has anyone else used this service before, if so, can I use it for passing multiple ips, or do i have to obtain some sort of license?" Had you have stated what you'd already done, we'd have seen that you're not just wanting someone to do it all for you and have taken the time to look yourself. As for me not wanting to help, I'm one of the first to have replied to your post with how I'd go about it to give you an idea of where to start. Regards Huggie
-
I'll probably be shot for this, but I think the way I'd do it is to have a job_detail table, a status table, and a job_status table. job_detail job_id -> unique primary key All your job details (doesn't include a status column) status id -> unique primary key status job_status job_id -> not unique, but possibly indexed status_id timestamp I don't see the point in having a status column in the job_details table as you'd need to update two tables when changing a status. An insert into one and an update on the other. I'd rather select from two than update/insert to two. And because no status column exists in the job_details table, there's no real need to have a unique primary key on the job_status table. I'm open to reasons as to why this isn't a good idea though, I'm no database expert. Regards Huggie
-
So what you're asking us to do is, go to the site, read about the product/service and report back to you? Here's a little suggestion... Why don't you read about it yourself Regards Huggie
-
The short answer is yes! I'd go about it two ways, firstly I'd search the web to find out if someone offers what I need for free and make a list of all the potential providers, then I'd see if any of them offer a web service/api that I can use without having to write some custom code. If the above fails then I'd create something using the cURL library. Regards Huggie
-
This is a limitation that your host has applied by the looks of it. Google brought me loads of results about it! Regards Huggie
-
I'd imagine that the reason these comments were made is that in both of those functions, the entire file is read into either a string or an array, however by using fopen(), fread(), fget() etc, you can get each line at a time. I'd imagine that when dealing with large files this makes it a whole lot more scalable! Regards Huggie
-
In that case, go with COM objects... Regards Huggie
-
First question, and very important... Is your server running a Windows OS? Regards Huggie
-
Try this: $campaign = preg_replace("/\\/", '', $campaign); Regards Huggie
-
You still need pattern delimeters in there... <?php $campaign = "ebook\'s"; $campaign = preg_replace('/\\/', '', $campaign); ?> More importantly though, where did the slash come from? In this instance where has ebook\'s come from? As PHP has functions for dealing with slashes. e.g stripslashes() Regards Huggie
-
php redirect depending on database number
HuggieBear replied to tommyinnn's topic in PHP Coding Help
Try the header() function... <?php if ($pictures_cnt == 0){ header('Location: index.php'); } else { header('Location: upload_photo.php'); } ?> Regards Huggie -
Use two backslashes.... The first will escape the second. Regards Huggie
-
There's no PHP function called curl_easy_setopt(). That's what the problem is. Regards Huggie
-
Calling javascript.js file from a php file
HuggieBear replied to jholstein's topic in PHP Coding Help
The code already has a form tag in it. It's just not included in this snippet. Take a look at the attached files in the earlier post... Regards Huggie