I have two virtual systems for development. First one is Windows + xampp (apache, php, mysql) and second one is Linux + apache + php + mysql. I have very very simple page that loads images from database (yes, images are in the database not on the filesystem, it is not the case here, is it right or not) using external links.
The first page shows photos:
<img src="photo.php?photo_id=4" height="127" width="127">
The second page loads them from database:
if (isset($_GET['photo_id'])) {
$link = getDBconnection();
$result = getPhoto($link, $_GET['photo_id']);
if ($result) {
$row = mysql_fetch_assoc($result);
header("Content-type: " . $row['MIMEtype']);
echo $row['photoImage'];
}
closeDBconnection($link);
}
Everything is working fine on the Windows machine but on the linux machine, pictures just don't show up. I mean image files from page directory loads up and shows up but somehow this external link stopped working. I've places few echos and for sure script executes and photoImage has binary data.
I wonder, is it just configuration issue (probable, am not configuring apache/php/mysql every day). I've stuck at that point. Any ideas?
PS. Database is exactly the same. I've just exported/imported it from Windows to Linux mysql database. Any other data is successfully selected from database. It's just the photos, that don't work.
SOLVED
Thanks Marc B for the tip about encoding. I was aware of the possible issue but completely forgot about it. After copying the files once more time to the LINUX machine via ftp, and after double checking that I did not change encoding (by editing any file), the photos showed up.
Some things to check:
Check for database errors - you say the photoImage field has binary data, so not likely, but never ever assume a database call succeeded
Check for early text output, causing the header() call to fail - it should be getting logged somewhere. Turn on display_errors/error_logging while developing, in any case, so you don't have to rummage around in logs to find out what's going wrong.
Hit the url manually in a browser and see what comes through. Perhaps there's some characterset translation going causing the image data to be corrupted (e.g. you're using a TEXT field instead of a BLOB).
Related
I'm currently moving sites from one server to another. In doing this, I'm setting up new dev environment to help test any issues we may have in moving the site.
I've already moved one site, quashing all issues. I've had some issues with the latest two sites.
My work flow normally is:
1) Export
2) Edit to dev URL in Sublime Text via find/replace
3) Import to DB
Importing a MySQL dump first gave me an error such as
"ERROR at line XXX: unknown command YYY"
In one such scenario, this seems to be caused by an encoding issue (STX) for some unknown character.
I can get such errors to go away by using MySQL flags such as:
-default-character-set=latin1 for the mysqldump and NOT using --default-character-set=utf8 with the import.
This gets me further in the process, as things seem to be working, except no images show in Media (just default.png) for the thumbs. I've verified that the files exist on the server and checked permissions. When clicking on an image in Media, I can copy/paste the URL and the image shows properly in a browser.
Another example of where the data isn't fully transferring is that the template used for a page isn't being retained.
I'm at a loss at this point on how to properly export/format/import the MySQL dump. I've even tried the WordPress repair database utility without any change in results.
O. Jones comment mentions a plugin called Duplicator. I didn't utilize this given our situation so I cannot speak to whether or not it would. If that would work correctly, I would imagine that the ideal solution for most.
The solution that I've utilized is simple but may not work for those without access to or unfamiliar with MySQL.
The steps are:
Export via "mysqldump -u {user} -p {databaseName} >
{filename.sql}
Import like usual (without issues)
Log into the new MySQL database where the import was completed, use that database and run the following queries:
UPDATE wp_options SET option_value = replace(option_value, '{oldURL}', '{newURL}');
UPDATE wp_posts SET guid = replace(guid, '{oldURL}', '{newURL}');
UPDATE wp_posts SET post_content = replace(post_content, '{oldURL}', '{newURL}');
UPDATE wp_postmeta SET meta_value = replace(meta_value, '{oldURL}', '{newURL}');
These four queries may need to be run for each variation of "http://oldwebsite.com", "http://www.oldwebsite.com", "https://oldwebsite.com", and "https://www.oldwebsite.com".
I'm writing a program using PHP and cUrl to save the HTML of a particular website to a server once in a while. I only want to actually save the file if something has changed on the website, though, so my question is: how do I compare a long text string (the newest HTML from cUrl) against an existing .txt file? The .txt file is approximately 700kB, to give you an idea of size. I'm mo
strcmp() is likely your best bet.
It returns 0 if the two strings are the same -
so
if(strcmp($savedHTML, $newHTML) !== 0) {
save($newHTML); // this would be your own function for saving
}
Of course, this will not work if there is a minor difference, such as a timestamp that has a different value each time.
I don't know how well behaved the server at the website you are saving is, but if it behaves properly and the website is coded properly it should return a 304 Not Modified status if nothing has changed.
I know they are a couple of big ifs, but you should check that before attempting anything else.
See the section on return values.
I have been running a website from home for a few months now and suddenly phpmyadmin is not showing me all the tables in the mysql database.
Here is a screenshot 1:
I thought the database could be corrupt or maybe someone has executed some bad sql code so I deleted the database and tried to restore from a date that I knew was working and the same thing happened. So I built a new server thinking something in phpmyadmin could be corrupt but now I am facing the same issue on the new server.
I tried manually creating the database but after so many tables have been created the same thing happens.
As you can see in the screenshot 1 on the left side it stops after customcars but then in the middle in continues to downloads. There should be more tables but they will not show up.
I have ran a script to check if they exist and they do but I just cannot access them on phpmyadmin
I have tried importing the database with a .sql file and still no luck.
Sometimes it evan looks like this
Notice the way the customcars on the left is missing and so is the X in the middle for downloads.
My Operating System Is Centos 6,
Mysql Version 5.1.73,
Phpmyadmin 2.11.11.3
Thank you for reading and I hope someone out there has had the same issue so I can fix this asap :)
You might want to check that Settings > Navigation Panel > Maximum items in branch is not set to a low number. http://docs.phpmyadmin.net/en/latest/config.html#cfg_MaxNavigationItems
I had the same issue. I found an eye symbol next to my database name in the left column. When I cliked on the eye symbol I had the option to unhide the missing table. I have no idea how I managed to hide this table but this solved my problem.
You might accidentally hide any table by clicking eye on PhpMyadmin. Click the eye icon then it appears a pop up to show the hidden table.
I was given an sql database that I was supposed to do some stuff on, and I want to clean it up, given that they have stuff with "special characters" as values, such as carcaças. Notice the `ç.
My Update command just simply doesn't want to work. I've checked in a million times and the weird part is on the webservice that I'm creating using that database the line seems to do nothing, but when I go on phpmyadmin it works perfectly. It has nothing to do with permissions given that its all being hosted on my computer.
So here you go the code:
function filter($stockconn){
mysqli_query($stockconn,"UPDATE produtos SET familiaprod='Carcacas' WHERE familiaprod='Carcaças'") or die(mysql_error());
mysqli_close($stockconn);
}
So far its all very simple, simple connection file (which is working correctly 100%) being pulled towards that function.
I'm running a simple piece of php code, like so:
echo file_get_contents( 'http://example.com/service?params' );
When I run the code on my local machine (at work) or from my shared hosting account, or if I simply open the URL in my browser, I get the following result:
{"instances":[{"timestamp":"2014-02-28 18:03:39.0","ids":[{"id":"525125875"}],"cId":179,"cInstanceId":9264183220}]}
However, when I run the exact same code on either of two different web severs at my workplace, I get the following slightly different result:
{"instances":[{"timestamp":"2014-02-28 18:03:39.0","ids":[{"id":"632572147"}],"cId":179,"cInstanceId":4302001980}]}
Notice how a couple of the numbers are different, and that's all. Unfortunately, these different numbers are the wrong numbers. The result should be identical to the first one.
The server I'm making the call to is external to my workplace.
I've tried altering the file_get_contents call to include headers and masquerade as a browser, but nothing seems to give a different result (well, other than an error due to an accidentally malformed request). I can't use cURL because it's not installed on the servers where this code needs to be deployed.
Any clue what could be causing the differing results? Perhaps something in the request headers? Although I'm not sure why something in the headers would cause the service to return different data.
thanks.
(edit)
The service URL I'm testing with is:
http://iswa.ccmc.gsfc.nasa.gov/IswaSystemWebApp/CygnetLastNInstancesServlet?lastN=1&cygnetId=179&endTimestamp=2014-02-28+21%3A35%3A48
The response it gives is a bit different than what I posted above; I simplified and shortened the responses in my SO post to make it easier to read--but the essential information given, and the differences, are still the same.
I give the service a timestamp, the number of images I want to fetch which were created prior to that timestamp, and a 'cygnetId', which defines what sort of data I want the images to show (solar wind velocity, radiation belt intensity, etc).
The service then echoes back some of the information I gave it, as well as URL segments for the images I requested.
With the returned data, I can build the URL for an image.
Here's the URL for an image built from a "correct" response:
http://iswa.ccmc.gsfc.nasa.gov/IswaSystemWebApp/StreamByDataIdServlet?allDataId=525125875
Here's the URL for an image built from a "wrong" response:
http://iswa.ccmc.gsfc.nasa.gov/IswaSystemWebApp/StreamByDataIdServlet?allDataId=632572147
If you click the links above, you'll see that the "wrong" URL does not open an image--the response is blank.