SA-MP Forums Archive
Dynamic Signatures - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dynamic Signatures (/showthread.php?tid=361753)



Dynamic Signatures - Swyft™ - 22.07.2012

Hey, I need some help. LIke always....

I am trying to make the thing to work but it just says Username is not in our database. Please try again.

signature.php code
pawn Код:
<?  
/*
***Made by: Nodroz***
*** Enjoy your signatures! ***
*/


$username="***"; //Your MySQL Username.
$password="***"; // Your MySQL Pass.
$database="***"; // Your MySQL database.
$host="***"; // Your MySQL host. This is "localhost" or the IP specified by your hosting company.

$player_name=$_GET['player_name']; // This gets the player his name from the previous page.

/* Next, we will make a connection to the mysql.  
If it can't connect, it'll print on the screen: Unable to select database. Be sure the databasename exists and online is. */


mysql_connect($host,$username,$password); // Connection to the database.
@mysql_select_db($database) or die( "Unable to select database. Be sure the databasename exists and online is."); //Selection of the database. If it can't read the database, it'll give an error.

/* To protect MySQL injection. */
$player_name = stripslashes($player_name);
$player_name = mysql_real_escape_string($player_name);



$query="SELECT * FROM users WHERE Playername='$player_name'"; // Gets all the information about the player.
$result=mysql_query($query);
$i=mysql_num_rows($result); // Here we are counting how many rows this result gives us.

/* We will now put the player's information into variables so we can use them more easily. */
/* DON'T FORGET: The names should be exact the same as in your mysql db.*/

if ($i == 1) // If the user has been correct, then it'll give us 1 row. If its 1 row, then it'll proceed with the code.
{
         
    $Playername=mysql_result($result,0,"Playername"); // Gets the username of the player and put it in the variable $Playername.
    $Money=mysql_result($result,0,"Money"); // Gets the money of the player and put it in the variable $Money.
    $Score=mysql_result($result,0,"Score"); // Gets the score of the player and put it in the variable $Score.


    // Creating of the .png image.  
    header('Content-Type: image/png;');
    $im = @imagecreatefrompng('mypicture.png') or die("Cannot select the correct image. Please contact the webmaster."); // Don't forget to put your picture there.
    $text_color = imagecolorallocate($im, 197,197,199); // RED, GREEN, BLUE --> Go to http://www.colorpicker.com, select a nice color. Copy the R/G/B letters provided by colorpicker and put them here.
    $text_username = "$Playername"; // This gets the information about player name to be showed in the picture.
    $text_score = "$Score"; // Same as above ^^
    $text_money = "$Money"; // Same as above ^^
    $font = 'myfont.ttf'; //Upload your custum font to the directory where this file is placed. Then change the name here.
    /* USAGE OF THE imagettftext: First ($im) shouldn't be changed. (16) is the text-size. (0) is the angle of your text. Change it, and you'll see what's going on. (20) is de X-coordinate of the text.
    (36) is the Y-coordinate of the text. */

    imagettftext($im, 16, 0, 20, 36, $text_color, $font, $text_username); // Prints the username in the picture.  
    imagettftext($im, 16, 0, 72, 69, $text_color, $font, $text_score); // Prints the score in the picture.
    imagettftext($im, 16, 0, 72, 99, $text_color, $font, $text_money); // Prints the money in the picture.
    imagepng($im);
    imagedestroy($im);
} else echo('Username is not in our database. Please try again.'); // If the username doesn't exist (so the row is 0) then it'll give en error.

mysql_close();

?>
In my actually SAMP Script

to find the username this is the line
pawn Код:
"SELECT * FROM `accounts` WHERE `Name` = '%s' LIMIT 1", pName
If you need anything else just reply, but I am new to MySQL, I know squat crap about it


Re: Dynamic Signatures - SomebodyAndMe - 22.07.2012

PHP код:
<?  
/* 
***Made by: Nodroz*** 
*** Enjoy your signatures! *** 
*/ 

$username="***"//Your MySQL Username. 
$password="***"// Your MySQL Pass. 
$database="***"// Your MySQL database. 
$host="***"// Your MySQL host. This is "localhost" or the IP specified by your hosting company. 

$player_name=$_GET['player_name']; // This gets the player his name from the previous page. 

/* Next, we will make a connection to the mysql.  
If it can't connect, it'll print on the screen: Unable to select database. Be sure the databasename exists and online is. */ 

mysql_connect($host,$username,$password); // Connection to the database. 
@mysql_select_db($database) or die( "Unable to select database. Be sure the databasename exists and online is."); //Selection of the database. If it can't read the database, it'll give an error. 

/* To protect MySQL injection. */ 
$player_name stripslashes($player_name); 
$player_name mysql_real_escape_string($player_name); 



$query="SELECT * FROM accounts WHERE Name = '$player_name'"// Gets all the information about the player. 
$result=mysql_query($query); 
$i=mysql_num_rows($result); // Here we are counting how many rows this result gives us. 

/* We will now put the player's information into variables so we can use them more easily. */ 
/* DON'T FORGET: The names should be exact the same as in your mysql db.*/ 

if ($i == 1// If the user has been correct, then it'll give us 1 row. If its 1 row, then it'll proceed with the code. 

         
    
$Playername=mysql_result($result,0,"Playername"); // Gets the username of the player and put it in the variable $Playername. 
    
$Money=mysql_result($result,0,"Money"); // Gets the money of the player and put it in the variable $Money. 
    
$Score=mysql_result($result,0,"Score"); // Gets the score of the player and put it in the variable $Score. 


    // Creating of the .png image.  
    
header('Content-Type: image/png;'); 
    
$im = @imagecreatefrompng('mypicture.png') or die("Cannot select the correct image. Please contact the webmaster."); // Don't forget to put your picture there. 
    
$text_color imagecolorallocate($im197,197,199); // RED, GREEN, BLUE --> Go to http://www.colorpicker.com, select a nice color. Copy the R/G/B letters provided by colorpicker and put them here. 
    
$text_username "$Playername"// This gets the information about player name to be showed in the picture. 
    
$text_score "$Score"// Same as above ^^ 
    
$text_money "$Money"// Same as above ^^ 
    
$font 'myfont.ttf'//Upload your custum font to the directory where this file is placed. Then change the name here. 
    /* USAGE OF THE imagettftext: First ($im) shouldn't be changed. (16) is the text-size. (0) is the angle of your text. Change it, and you'll see what's going on. (20) is de X-coordinate of the text. 
    (36) is the Y-coordinate of the text. */ 
    
imagettftext($im1602036$text_color$font$text_username); // Prints the username in the picture.  
    
imagettftext($im1607269$text_color$font$text_score); // Prints the score in the picture. 
    
imagettftext($im1607299$text_color$font$text_money); // Prints the money in the picture. 
    
imagepng($im); 
    
imagedestroy($im); 
} else echo(
'Username is not in our database. Please try again.'); // If the username doesn't exist (so the row is 0) then it'll give en error. 

mysql_close(); 

?>



Re: Dynamic Signatures - Swyft™ - 22.07.2012

remove


Re: Dynamic Signatures - Swyft™ - 22.07.2012

I have been trying other methods, but no luck soo far.


Re: Dynamic Signatures - Swyft™ - 23.07.2012

I'm in desperate need for help, I don't care for another infraction atm.


Re: Dynamic Signatures - MP2 - 23.07.2012

This is the samp forum, not a php forum. You'd get much better help elsewhere.


Re: Dynamic Signatures - Swyft™ - 23.07.2012

-,-............


Re: Dynamic Signatures - ca2k - 23.07.2012

Here you go: http://forums.phpfreaks.com/

Your query looks like this..

PHP код:
$query="SELECT * FROM users WHERE Playername='$player_name'"
and as I see you don't even have the users table

Код:
"SELECT * FROM `accounts` WHERE `Name` = '%s' LIMIT 1", pName
Even if you fix the table name or query it won't work because you probably didnt upload 'myfont.tft' and you will see a blank image.

And again: http://forums.phpfreaks.com/


Re: Dynamic Signatures - Swyft™ - 23.07.2012

i already changed it too that but still no luck


Re: Dynamic Signatures - ca2k - 23.07.2012

Quote:
Originally Posted by RockingCamman
Посмотреть сообщение
i already changed it too that but still no luck
Show your .sql dump without the data.