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.
Related
I'm having this issue with the JSONAPI for minecraft. http://mcjsonapi.com/
I am trying to use the method "files.write" or "setFileContents" to replace the contents of a file. The website states this about the method.
Pretty simple. Just rewrites the file right? Yeah but this is proving to be more difficult then I thought. At first attempt, I was trying to set 3450 characters to the file "groups.yml" on the minecraft server. Here's the code I ran in PHP:
var_dump(
$api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", (string)$yaml))
);
The var_dump is supposed to either return a success statement or an error describing what went wrong. But instead all I get is "null". This isn't right, and I know $yaml is being casted to a string, which isn't the issue. So I decide to start testing around. After much testing, I find that the character length of what I can set is exactly 1622. Adding another space or anything causes null, otherwise, it works. This is the modified file that is below 1622 characters I tested with.
So great, you found the issue, right? No, I didn't. I thought 1622 was an odd number to stop working, so I did some further testing. I tried to set 3000 characters I generated from just smashing my keyboard, and it worked! So what's going on here?
This and this works, but this doesn't. Why is this? This app called Adminium runs this exact API, and includes a file management system inside the app which I am assuming uses the same methods I am using, but it doesn't have a problem.
I have a forum post here that I also asked on, and still haven't gotten to an answer yet.
This is the thread I opened on ACF's website.
This is the website in question
But basically my local version of the site works without a hitch but when I pushed it live it fails.
I haven't heard from the ACF guru in a couple days but, picking up where we left off, the closest I can figure the problem is has something to do with get_the_id() returning int(1078) instead of int(1) like it should being that the database is brand new and the "Hello World" is the first and only post.
What's also weird is the title is correct but and half of the content exists but nothing I've done can get it to display.
Has anyone ever seen anything like this before? Is there a good reason why get_the_id() returns the right post id on my local installation?
You could try to make a copy of your local database and replace every localhost with the correct site url. After that execute this SQL in your production environment. Probably your database is messed up.
I have worked with MySQL before but it has been a LONG time ago. Now I am trying to set up a database using phpMyAdmin.
I am trying to setup this database for the Article Friendly script. The instructions state that you need to use a little script that they have furnished:
define("DB_NAME","a6852953_article");
define("SERVER_NAME","'mysql12.000webhost.com'");
define("USER_NAME","a6852953_article");
define("PASSWORD","*********");
$dbhost=SERVER_NAME;
$dbuser=USER_NAME;
$dbpasswd=PASSWORD;
$dbname=DB_NAME;
It chokes on the first line, and if I remove that it chokes on whatever is there.
The syntax looks correct to me with what little I remember and I also checked the manual for 5.1 which is what my host uses.
Can anyone spot anything wrong?
Looks like it might actually be choking on the second line...
define("SERVER_NAME","'mysql12.000webhost.com'");
... likely because you have single quotes inside the double quotes. Try changing the line to this:
define("SERVER_NAME","mysql12.000webhost.com");
If it is the first line however, make sure that the database you listed already exists -- if not, you should be able to login to phpMyAdmin and run:
CREATE DATABASE a6852953_article
:)
Seems phpmyadmin trims the end of the sql output when running operation commands ..
I really need phpmyadmin to show the full output
Any Ideas?
After a quick search on Google i found this: http://wiki.phpmyadmin.net/pma/Config#MaxCharactersInDisplayedSQL
It seems that you just have to edit the config file of PHPmyadmin and set $cfg['MaxCharactersInDisplayedSQL'] = 1000; to the value you want.
My problem was even more simple. I was using "show create table", but the result was truncated after a handful of chars.
PHPMyAdmin actually has a small "+options" link over the results, with simple options like "truncate results". Just needed to untick that !
If you want to edit the files mentionned by Torr, look for :
config.default.php, in 'librairies" folder, which contains existing parameters
config.inc.php, where you should copy/paste the ones you need to.
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).