Posts Tagged ‘error’

You have an error in your SQL syntax

I find MySQL’s error messages pretty annoying due to how vague they usually are.
SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near blah blah blah at line #
Not helpful.
I was doing a very simple INSERT into a [...]

Invalid Authenticity Token Error in Rails

Got the following error today when trying to submit a form in Ruby on Rails:
ActionController::InvalidAuthenticityToken
The solution turned out to be as easy as inserting

into my form.
[via Nabble]

Header Location Redirect Not Working in PHP?

Ran into a bug this evening when I was trying to redirect to a different page in PHP. I was trying to do the following:
if(blah blah blah) {

echo "some text here";

header("Location: http://www.example.com/");
}
The problem was that it wasn’t doing anything, even when the if condition was satisfied. It was printing [...]

Fatal error: Call to undefined function: file_put_contents()

Two functions that I’ve found invaluable recently have been file_get_contents() and file_put_contents(). When used along with serialize(), these have allowed me to maintain very simple “databases” using files in the directory, rather than having to store data in specially made MySQL tables.
One of the interesting things I discovered when trying to use these functions on [...]

Divide by Zero Errors in Postgresql

Let’s say you’re working with Postgresql (applicable to other DBMSs as well), and you come across the following error when trying to execute a select query involving division:
ERROR: division by zero
You would think Postgresql would play nice, and set all the invalid fields to NULL or 0, but instead it chooses to spit out [...]

Working With Tweet IDs in PHP

I was playing with the Twitter search API today when I came across a strange problem. I was storing the unique ID of a tweet in the database as a string, and after bringing it out was trying to convert it back to an integer. However, the following code:
// this was the string of the [...]

Mismatched Key Data Types in Rails and Postgresql

I switched my database over from sqlite3 to postgresql for an application I’m developing for my MS research, and suddenly received this error when I tried to run my application:
Moperator does not exist: integer = character varying
After a little searching and poking, I found out that I had accidentally set up one of my foreign [...]