This is so easy I almost don't believe it, except I've tested it and it works.
$create = mysql_query("CREATE DATABASE IF NOT EXISTS databasename");
Crazy easy, no?
A diary about programming problems - to help me more easily learn from (and Google) past mistakes.
Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts
Thursday, 22 March 2012
Friday, 6 August 2010
Line breaks
OK, so...
I am entering text in a flash text field, which gets sent to a mysql database. This later gets retrieved by php, and folded into a javascript function, so that another swf can use that data.
The problem is, if there are any line breaks in the initial text, then that ends up in the javascript function, and is seen as an error.
So to solve it, I will attempt to get the php file that takes the text out of the database, to convert that line break into something that the javascript function can stand, and that the swf can interpret.
Continuation -
Yeah, that worked. First I tried nl2br, which is supposed to put html linebreak tags where the line breaks are, although I din't see this effect. But this would have required me to make changes to my flash file.
So I used:
$lineBreaks = Array("\n","\r");
$iQuestion = ...get text from MySQL database
$oQuestion = str_replace($lineBreaks,'\u000d',$iQuestion);
$lineBreaks is an array of possible ways in which the line breaks may come down, I wasn't sure if this would differ depending on the user's operating system etc.
I am entering text in a flash text field, which gets sent to a mysql database. This later gets retrieved by php, and folded into a javascript function, so that another swf can use that data.
The problem is, if there are any line breaks in the initial text, then that ends up in the javascript function, and is seen as an error.
So to solve it, I will attempt to get the php file that takes the text out of the database, to convert that line break into something that the javascript function can stand, and that the swf can interpret.
Continuation -
Yeah, that worked. First I tried nl2br, which is supposed to put html linebreak tags where the line breaks are, although I din't see this effect. But this would have required me to make changes to my flash file.
So I used:
$lineBreaks = Array("\n","\r");
$iQuestion = ...get text from MySQL database
$oQuestion = str_replace($lineBreaks,'\u000d',$iQuestion);
$lineBreaks is an array of possible ways in which the line breaks may come down, I wasn't sure if this would differ depending on the user's operating system etc.
Labels:
as3,
Javascript,
line breaks,
mysql,
php,
str_replace
Monday, 10 May 2010
Getting data from MySQL
Today, I have been mostly... not getting data from a MySQL database.
I thought I had this sorted already - I had a script that could send data to a php script, then receive a query string and format the data as a URL variable.
As usual, when you try to actually use it for something - it turns out to be more complicated.
First of all, using capital letters in the query string that PHP is outputting is apparently not a good idea! Can you imagine?!? It took me three hours just to pin the problem down to that!
So then I though I had the problem sorted, but no.
I think it might be something to do with the length of the query string...
More on this later?
I thought I had this sorted already - I had a script that could send data to a php script, then receive a query string and format the data as a URL variable.
As usual, when you try to actually use it for something - it turns out to be more complicated.
First of all, using capital letters in the query string that PHP is outputting is apparently not a good idea! Can you imagine?!? It took me three hours just to pin the problem down to that!
So then I though I had the problem sorted, but no.
I think it might be something to do with the length of the query string...
Subscribe to:
Posts (Atom)