PHPMyAdmin: Table specific privileges

If you like to grant a user special privileges, like for example, only run select queries on a table, then PHPMyAdmin is your friend.

1. Go to the user settings
2. leave the global settings blank
3. under database specific, choose your database.
4. in the table specific, opt for the table you wish to add.
5. in the select column, select all fields that can be used for select queries.
6. check show_view and Create_view

That’s all :)

Most wanted Ajax stuff

Today Noupe posted an overview of the most wanted ajax techniques. A list of over 50 solutions for common javascript problems. Librarys used include JQuery, Prototype and Mootools. It’s a good checklist if you need something special, done quick. I especially like wTag and Starbox. Thanx Noupe.

wTag

IGoogle moving gadgets

With the new Igoogle it’s no longer possible to move gadgets from one tab to another.
For the time being you can move your gadgets with the old layout at:
http://www.google.com/ig?gl=all
It’s very likely that this url won’t be available for long. It only exists because not all countries have switched to the new layout. Enjoy while you can ^_^

Related Blogs

  • Related Blogs on

Heatmaps

While cleaning out some old code folders, I ran accros an old project of mine. A PHP heatmap sollution. This got me thinking about it again. Now that the buzz about headmaps is gone, what sollutions are there?

Here are some links to get you started:

http://blog.corunet.com/english/the-definitive-heatmap
http://www.techyard.net/6-ways-to-create-heat-maps-for-your-blogs/

Adding leading zero’s and id’s with php

For a project of mine I had to make a dynamic filename
We decided that the name should always be seven digits long and the file would be correspondentĀ  to the line number in the database. For example line seven would link to a file 0000007.txt.

code for the id from MySQL
$mynr = mysql_insert_id();

code for the seven digits
$mynr = sprintf(“%07d”,$mynr);

Related Blogs

  • Related Blogs on

PHP, MySQL and utf-8

When creating forms with french content, I got strange characters in my database.
The solution was to put some utf-8 declaration at the top of the php pages and to add some extra code for mysql.

php:

<?
php header(‘content-type: text/html; charset: utf-8′);
mb_internal_encoding( ‘UTF-8′ );
?>

MySQL:
add the following code after you make a connection and before you run a query
mysql_query(“SET NAMES ‘utf8′”);
mysql_query(“SET CHARACTER SET utf8″);

Additionally you could also add accept-charset=”utf-8″ to your form tags.

Javascript date object

var mytime = new Date()
var mymonth = mytime.getMonth() + 1 // for javascript january = 0  correct this by adding 1
var myday = mytime.getDate()
var myyear = mytime.getFullYear()
document.write(mymonth + "/" + myday + "/" + myyear)
Beware that this is the date on the client's computer. For forms use the date on your server.

Related Blogs

  • Related Blogs on

Checking radiobuttons with Prototype

example:
<input type='radio' name='test' value='1' />
<input type='radio' name='test' id='nr2' value='2' />
<input type='radio' name='test' value='3' />

$$("input[type=radio][name='test'][value='3']")[0].writeAttribute("checked", "checked");
or
$("nr2").writeAttribute("checked", "checked");

Related Blogs

PDFlib basics

$imagefile = “mybackground.tif”;

$outfilename = “”; //empty if you want to work in memory, else use filename

$p = PDF_new();

PDF_set_parameter($p, “license”, “your licensenr”);//call before anything else
PDF_set_parameter($p, “errorpolicy”, “return”);
PDF_set_parameter($p, “textformat”, “utf8″); // use utf8
//mysql_real_escape_string breaks variables with utf8 data

if (PDF_begin_document($p, $outfilename, “”) == 0) {
die(“Error: ” . PDF_get_errmsg($p));// if you can’t create the document return the error
}

PDF_set_info($p, “Creator”, “My name”);// place your name inside the pdf info
PDF_set_info($p, “Title”, “My title”); // give the pdf a title

PDF_begin_page_ext($p, 595, 842, “topdown”); // begin a page, these are settings for A4 size. coordinates start top left

$font = PDF_load_font($p, “Helvetica”, “unicode”, “”); // set the font
if ($font == 0) {
die(“Error: ” . PDF_get_errmsg($p)); // return errormessage if fontsettings are wrong
}
PDF_setfont($p, $font, 10);

/* place image in the background*/
$image = PDF_load_image($p, “auto”, $imagefile, “”);
if ($image == 0) {die(“Error: ” . PDF_get_errmsg($p));} // if failed, return the errormessage
PDF_fit_image($p,$image, 1, 842, “”); // place the image
PDF_close_image($p, $image);

/* textflow example*/
$mytext = “this is<nextline>some text<nextline>on multiple lines”;
$mytextflow = PDF_create_textflow($p,$mytext, “fontname=arial fontsize=8 encoding=unicode leading=12″);
PDF_fit_textflow($p, $mytextflow, 289, 122, 400, 400, “”);

/* working with fit_textline */
$optlist1= “boxsize={355 14} position={top left}”; // box is 355 width and 14 height, draw text top left
PDF_fit_textline($p,”test for fit_textline”, 36, 120, $optlist1);

/*draw rectangle*/

PDF_rect($p, 36, 755, 520, 107);
PDF_stroke($p);

PDF_end_page_ext($p, “”); // end of page

PDF_end_document($p, “”); // end of document
// $document = pdf_get_buffer($p); use this to capture the pdf from memory ->$outputfile should be empty

PDF_delete($p);

Related Blogs

Browsersniffing with CSS

After some research I found the follow css code for sniffing out browsers and emailclients through css. /*Internet Explorer*/
<!--[if IE 7]>
.glue{color: black;}
<![endif]-->

<!–[if IE 6]>
.glue{color: blue;}
<![endif]–>

/* outlook 2007*/

<!--[if gte mso 9]>
.glue{color: aqua;}
<![endif]-->

/* Firefox */
@-moz-document url-prefix() {

.glue { color: red; }
}

/* Opera */
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { .glue { color: yellow; }
}