Tatara
-
Posts
12 -
Joined
-
Last visited
Never
Posts posted by Tatara
-
-
Alright guys(and gals), I'm trying to code a bank for a person on Gaiaonline. I think i can get most of it down but the admin panel. I don't want to use an .htpasswd. I would rather have a phpBB style authentication. Any help is appreciated.
-
youngcoders.com is a good help site but i never got the activation email
any ways thanks for answering -
Whats the difference?
What i want is to be able to call the image from http://www.mysite.com/user.png wher it takes the name of the ping and queries the database for that user and return the info. -
I want to make it where the http get var from the file name so i can call it form [i]user[/i].png
code already worked out:
[code]<?php
$con = mysql_connect("host","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if(!mysql_select_db("db", $con)) {
die('Could not connect: ' . mysql_error());
}
//used to find which user to query for in the database
$user = mysql_real_escape_string(trim($HTTP_GET_VARS['user']));
// Query
$sql = "SELECT item,have,need FROM row WHERE user = '$user'";
// Run Query
$result = mysql_query($sql) or die("Error retrieving user info: ".mysql_error());
// Grab the user results
while( $row = mysql_fetch_array($result) ){
$item = $row['item'];
$have = $row['have'];
$need = $row['need'];
}
$height = 25;
$width = 200;
$fontsize = 6;
$frac = $have/$need;
$pct = 100 * $frac;
$img = imagecreate($width,$height);
$red = imagecolorallocate($img,255,0,0);
$black = imagecolorallocate($img,0,0,0);
$white = imagecolorallocate($img,255,255,255);
$bg = imageCreateFromPNG ('bg.png');
$bar =imageCreateFromPNG ('fill.png');
imageSetTile ($img, $bg);
imageFilledRectangle ($img, 0, 0, 116, 40, IMG_COLOR_TILED);
imageSetTile ($img, $bar);
ImageFilledRectangle($img, 7, 22, (114 * $frac), 34, IMG_COLOR_TILED);
$font = '04B_09__.ttf';
$text1 = "Questing For";
$text2 = $item;
$text3 = $have . "/" . $need;
$textwidth1 = floor(imagefontwidth($font) * strlen($text1));
$textleft1 = (($width - $textwidth1) / 2) + 12;
$textwidth2 = floor(imagefontwidth($font) * strlen($text2));
$textleft2 = (($width - $textwidth2) / 2) + 12;
imagettftext($img, $fontsize, 0, $textleft1, 8, $white, $font, $text1);
imagettftext($img, $fontsize, 0, $textleft2, 19, $white, $font, $text2);
imagettftext($img, 6, 0, 46, 32, $black, $font, $text3);
header('content-type: image/png');
imagepng($img);
?>[/code] -
also many host have the gd library already installed with php and as of PHP 4.3 there is a bundled version of the gd library
-
ok i wrote a script with the help of ppl here to do a quest bar it connects to a sql database but it outputting the image wrong it should look like this [IMG]http://i80.photobucket.com/albums/j183/wmbandgeek88/test2.png[/img] but it looks like this [IMG]http://i80.photobucket.com/albums/j183/wmbandgeek88/bar.png[/img]
heres the code:
[code]<?php
$con = mysql_connect("localhost","tatara","102188");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if(!mysql_select_db("questbar_db", $con)) {
die('Could not connect: ' . mysql_error());
}
//used to find which user to query for in the database
$user = mysql_real_escape_string(trim($HTTP_GET_VARS['user']));
// Query
$sql = "SELECT item, have, need FROM questbar WHERE user = '$user'";
// Run Query
$result = mysql_query($sql) or die("Error retrieving user info: ".mysql_error());
// Grab the user results
while( $row = mysql_fetch_array($result) ){
$item = $row['item'];
$have = $row['have'];
$need = $row['need'];
}
// You can get rid of these
//change these to get the value from the results of the query
//$item = $HTTP_GET_VARS['item'];
//$have = $HTTP_GET_VARS['have'];
//$need = $HTTP_GET_VARS['need'];
$height = 25;
$width = 200;
$fontsize = 6;
$frac = $have/$need;
$pct = 100 * $frac;
$img = imagecreate($width,$height);
$red = imagecolorallocate($img,255,0,0);
$black = imagecolorallocate($img,0,0,0);
$white = imagecolorallocate($img,255,255,255);
$bg = imageCreateFromPNG ('bg.png');
$bar =imageCreateFromPNG ('fill.png');
imageSetTile ($img, $bg);
imageFilledRectangle ($img, 0, 0, 116, 40, IMG_COLOR_TILED);
imageSetTile ($img, $bar);
ImageFilledRectangle($img, 7, 22, (114 * $frac), 34, IMG_COLOR_TILED);
$font = 'arial.ttf';
$text1 = "Questing For";
$text2 = $item;
$text3 = $have . "/" . $need;
$textwidth1 = floor(imagefontwidth($font) * strlen($text1));
$textleft1 = (($width - $textwidth1) / 2) + 12;
$textwidth2 = floor(imagefontwidth($font) * strlen($text2));
$textleft2 = (($width - $textwidth2) / 2) + 12;
imagettftext($img, $fontsize, 0, $textleft1, 8, $white, $font, $text1);
imagettftext($img, $fontsize, 0, $textleft2, 19, $white, $font, $text2);
imagettftext($img, 6, 0, 46, 32, $black, $font, $text3);
header('content-type: image/png');
imagepng($img);
?>[/code] -
Thanks Im a noob at php scripting
-
ok im still having trouble its connecting to the database and pulling the data but instead of looking like this
[IMG]http://i80.photobucket.com/albums/j183/wmbandgeek88/test2.png[/img] it looks like this [IMG]http://i80.photobucket.com/albums/j183/wmbandgeek88/bar.png[/img]
heres the code again
[code]<?php
$con = mysql_connect("localhost","myusername","mypassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if(!mysql_select_db("mydatabase", $con)) {
die('Could not connect: ' . mysql_error());
}
//used to find which user to query for in the database
$user = mysql_real_escape_string(trim($HTTP_GET_VARS['user']));
// Query
$sql = "SELECT item, have, need FROM questbar WHERE user = '$user'";
// Run Query
$result = mysql_query($sql) or die("Error retrieving user info: ".mysql_error());
// Grab the user results
while( $row = mysql_fetch_array($result) ){
$item = $row['item'];
$have = $row['have'];
$need = $row['need'];
}
// You can get rid of these
//change these to get the value from the results of the query
//$item = $HTTP_GET_VARS['item'];
//$have = $HTTP_GET_VARS['have'];
//$need = $HTTP_GET_VARS['need'];
$height = 25;
$width = 200;
$fontsize = 6;
$frac = $have/$need;
$pct = 100 * $frac;
$img = imagecreate($width,$height);
$red = imagecolorallocate($img,255,0,0);
$black = imagecolorallocate($img,0,0,0);
$white = imagecolorallocate($img,255,255,255);
$bg = imageCreateFromPNG ('bg.png');
$bar =imageCreateFromPNG ('fill.png');
imageSetTile ($img, $bg);
imageFilledRectangle ($img, 0, 0, 116, 40, IMG_COLOR_TILED);
imageSetTile ($img, $bar);
ImageFilledRectangle($img, 7, 22, (114 * $frac), 34, IMG_COLOR_TILED);
$font = 'arial.ttf';
$text1 = "Questing For";
$text2 = $item;
$text3 = $have . "/" . $need;
$textwidth1 = floor(imagefontwidth($font) * strlen($text1));
$textleft1 = (($width - $textwidth1) / 2) + 12;
$textwidth2 = floor(imagefontwidth($font) * strlen($text2));
$textleft2 = (($width - $textwidth2) / 2) + 12;
imagettftext($img, $fontsize, 0, $textleft1, 8, $white, $font, $text1);
imagettftext($img, $fontsize, 0, $textleft2, 19, $white, $font, $text2);
imagettftext($img, 6, 0, 46, 32, $black, $font, $text3);
header('content-type: image/png');
imagepng($img);
?>[/code] -
bump
-
Ok ill comment what i want in the coding. I know how to code the connection and the query but i do not know how to add it to the variable
[code]<?php
//add $user = $HTTP_GET_VARS['user'];
//used to find which user to query for in the database
//change these to get the value from the results of the query
$item = $HTTP_GET_VARS['item'];
$have = $HTTP_GET_VARS['have'];
$need = $HTTP_GET_VARS['need'];
$height = 40;
$width = 116;
$fontsize = 6;
$frac = $have/$need;
$pct = 100 * $frac;
$img = imagecreate($width,$height);
$red = imagecolorallocate($img,255,0,0);
$black = imagecolorallocate($img,0,0,0);
$white = imagecolorallocate($img,255,255,255);
$bg = imageCreateFromPNG ('bg.png');
$bar =imageCreateFromPNG ('fill.png');
imageSetTile ($img, $bg);
imageFilledRectangle ($img, 0, 0, 116, 40, IMG_COLOR_TILED);
imageSetTile ($img, $bar);
ImageFilledRectangle($img, 7, 22, (114 * $frac), 34, IMG_COLOR_TILED);
$font = '04B_09__.ttf';
$text1 = "Questing For";
$text2 = $item;
$text3 = $have . "/" . $need;
$textwidth1 = floor(imagefontwidth($font) * strlen($text1));
$textleft1 = (($width - $textwidth1) / 2) + 12;
$textwidth2 = floor(imagefontwidth($font) * strlen($text2));
$textleft2 = (($width - $textwidth2) / 2) + 12;
imagettftext($img, $fontsize, 0, $textleft1, 8, $white, $font, $text1);
imagettftext($img, $fontsize, 0, $textleft2, 19, $white, $font, $text2);
imagettftext($img, 6, 0, 46, 32, $black, $font, $text3);
header('content-type: image/png');
imagepng($img);
?>[/code] -
I want to create a script that creates an image on the fly based on one $HTTP_GET_VARS and two or three sql commands
this is the base for what i want but instead of using the http_get_vars function i want to call the data from a database the only HTTP_GET_VARS i want is a 'user'
[code]<?php
$item = $HTTP_GET_VARS['item'];
$have = $HTTP_GET_VARS['have'];
$need = $HTTP_GET_VARS['need'];
$height = 40;
$width = 116;
$fontsize = 6;
$frac = $have/$need;
$pct = 100 * $frac;
$img = imagecreate($width,$height);
$red = imagecolorallocate($img,255,0,0);
$black = imagecolorallocate($img,0,0,0);
$white = imagecolorallocate($img,255,255,255);
$bg = imageCreateFromPNG ('bg.png');
$bar =imageCreateFromPNG ('fill.png');
imageSetTile ($img, $bg);
imageFilledRectangle ($img, 0, 0, 116, 40, IMG_COLOR_TILED);
imageSetTile ($img, $bar);
ImageFilledRectangle($img, 7, 22, (114 * $frac), 34, IMG_COLOR_TILED);
$font = '04B_09__.ttf';
$text1 = "Questing For";
$text2 = $item;
$text3 = $have . "/" . $need;
$textwidth1 = floor(imagefontwidth($font) * strlen($text1));
$textleft1 = (($width - $textwidth1) / 2) + 12;
$textwidth2 = floor(imagefontwidth($font) * strlen($text2));
$textleft2 = (($width - $textwidth2) / 2) + 12;
imagettftext($img, $fontsize, 0, $textleft1, 8, $white, $font, $text1);
imagettftext($img, $fontsize, 0, $textleft2, 19, $white, $font, $text2);
imagettftext($img, 6, 0, 46, 32, $black, $font, $text3);
header('content-type: image/png');
imagepng($img);
?>[/code]
Can anybody help
How to code an admin panel
in PHP Coding Help
Posted
sorry..