-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
That's not working. It's just making the spacing bigger.
-
<?php function protect($input) { $escaped_input = mysql_real_escape_string(urldecode($_POST['input'])); // $sql = "INSERT INTO table VALUES ('$escaped_input')"; $input = mysql_real_escape_string($input); $input = eregi_replace("%","",$input); $input = eregi_replace("--","",$input); $input = htmlspecialchars(mysql_real_escape_string($input)); return $input; } $username = $_GET['username']; protect($username); $font = $_GET['font']; protect($font); $color = $_GET['color']; protect($color); $sql = "SELECT * FROM `users` WHERE `username` ='$username'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ $text = "This user does not exist!"; }else { $row = mysql_fetch_assoc($res); $text = "Username: $username // Forum Posts: $row[post_count]"; } // create a 100*30 image $im = imagecreate(500, 98); // white background and blue text $bg = imagecolorallocate($im, 255, 255, 255); $array2 = array('black','red','blue','green','purple','grey'); if(in_array($color,$array2)){ switch($color){ case black: $textcolor = imagecolorallocate($im, 0, 0, 0); break; case red: $textcolor = imagecolorallocate($im, 255, 0, 0); break; case blue: $textcolor = imagecolorallocate($im, 0, 0, 255); break; case green: $textcolor = imagecolorallocate($im, 0, 128, 0); break; case purple: $textcolor = imagecolorallocate($im, 128, 0, 128); break; case grey: $textcolor = imagecolorallocate($im, 128,128,128); break; } }else { $textcolor = imagecolorallocate($im,0,0,0); } // write the string at the top left $array = array(1,2,3,4,5); if(in_array($font,$array)){ switch($font){ case 1: $font = imageloadfont("andale12.gdf"); break; case 2: $font = imageloadfont("bmreceipt.gdf"); break; case 3: $font = imageloadfont("8x13iso.gdf"); break; case 4: $font = imageloadfont("bmcorrode.gdf"); break; case 5: $font = imageloadfont("bettynoir.gdf"); break; } }else { $font = imageloadfont("andale12.gdf"); } imagestring($im,$font, 5, 10, $text, $textcolor); // output the image header("Content-type: image/png"); imagepng($im); ?>
This is my current file.
How would I be able to put a break in the text?
-
Ha. It looks very simple, but it looks confusing.
Is it possible to load an external image?
-
You use tilde's not apostrophes when calling a table.
And you can't select one thing from another query, do:
$row2 = mysql_fetch_assoc($query1); $sql = SELECT * FROM `Faculty` WHERE `LastName` ='$row2[LastName]'";
-
Do SELECT * FROM `Faculty`
-
The session isn't set then Try echoing off the session before trying to locate somewheres else.
-
ALTER TABLE `TABLENAME` AUTO_INCREMENT =1000
If you don't want to use that SQL query you can go into your PHPMyAdmin, select the database, select the table, hit the Operations tab on the top, scroll down a little, and change AUTO INCREMENT to 1000
-
In terms of advertising a website using a banner and referral link.
I've written the mod rewrite for this.
My problem is: How would I go about using a premade banner and printing unique text on it for each users banner.
So:
http://website.org/userpics/marcus.png
Say I had: 800 forum posts
I wanted it to say: Username: marcus // Forum Posts: 800
Doing this by a SQL query.
$username = $_GET['username']; protect($username); //pre-made function to protect variable $sql = "SELECT * FROM `users` WHERE `username` ='$username'"; //username being marcus, atm $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ $text = "This user does not exist!"; }else { $sql2 = "SELECT * FROM `replies` WHERE `username` ='$username'"; $res2 = mysql_query($sql2) or die(mysql_error()); $num = mysql_num_rows($res2); $text = "Username: $username // Forum Posts: $num"; }
RewriteRule ^userpic/([^/]*)\.png$ /userpics.php?username=$1 [L]
How would I go about (probably using GD) to make the text ($text) print on the image?
-
-
Like, order by time?
Make a time field in your topics table and set it to int 25
Then while somebody posts a reply to that, update the time with time() to that topic id, and then just order by time
-
Works perfectly, thanks:)
-
You should be able to do:
<img type="image/png" src="data:image/png;base64,$imgdata">
-
Ok, I've tried that, and it didn't work.
$matches = "[quote=marcus]dood you're so sexy[/quote]"; $matches = preg_match('/[quote=(\w+)](.*?)[\/quote]/',$_POST['your_text_box'],$matches); echo "$matches[1] said:<br><div id=\"quote\">$matches[2]</div>";
-
-
I am making a forums system, and I wanted the ability to have users be able to quote people.
I have a little javascript thing, that would input:
[quote=username]their message[/quote]
into the text box.
How would I implement str_replace to make it show up as:
USERNAME said:<br> <div id="quote">THEIR MESSAGE</div>
-
You do have session_start(); in the config, correct?
-
Well I want the link the act the same way as the input button I have posted.
-
Oh, your function works, but predefining it within the variable will eliminate the definition.
-
If you want, you can do:
1. Add a time field in your users table and update it each time a logged in user goes to a new page
2. Then:
$count_time = time(); $count_time = $count_time-900; //a difference of 15 minutes $online_count = mysql_query("SELECT * FROM `users` WHERE `time`>=$count_time ORDER BY `page` DESC"); echo "<center><table cellspacing=3 cellpadding=3 width=300><tr><td class=bar><center><font class=barfont>Online List</td></tr>"; while($row = mysql_fetch_array($online_count)) { $username = $row['username']; echo "<tr><td><center> <a href=/user/$username> $username </a> </td></tr> "; } echo "</table>";
This should produce a list like:
Online List
marcus
yasuragi
Charlie
hxcChaos
Jakobo
ulitrexx
Caress
Ryan
sadie_bledsoe
angela
peachiekeen
Decco
cyllarus
ninjacore_xxlily
Jen
lynne
kim
-
If a variable is defined again in single quotes it will be as written as the variable name, not the definition of the variable.
$email = "admin@neoblob.com"; echo '$email'; //this would produce $email, instead of admin@neoblob.com //in your case $to actually is defined as $semail, not the email you specified
-
Why not use the direct code from php.net?
$pspell_link = pspell_new("en", "", "", "",(PSPELL_FAST|PSPELL_RUN_TOGETHER));
-
You don't echo the result of a mail function.
Do:
if($mail_sent = mail( $to, $subject, $message, $headers )){ echo "Mail sent"; }else { echo "Error sending mail"; }
-
htmlspecialchars will replace certain characters into their ASCII form.
For example:
A < will be replaced as <
A > will be replaced as >
The safest way (in my opinion) would to use mysql_real_escape_string() before you enter information into your database.
-
This is a function I've been using for quite some time to ensure all $_GET variables I'm using in SQL queries are safe from injection attacks:
// Quote variable to make safe for use in MySQL queries function quoteSmart($value) { // Trim whitespace $value = trim($value); // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not a number or a numeric string if (!is_numeric($value)) { $value = mysql_real_escape_string($value); } return $value; }
So to make your $_GET['userid'] variable safe just do:
$userid = quoteSmarty($_GET['userid']);
You should't do that, for the most part it won't work.
$userid = $_GET['userid']; quoteSmarty($userid);
Pagination Help
in PHP Coding Help
Posted
I am creating pagination for forums, to limit 20 rows per page. I have the limiting correct, but when it comes to echoing the "Previous PAGENUMBERS Next" part it shows:
Previous 1 Next
It shows this even when there should be 5 pages. Also, the Previous 1 and Next are not linked, Previous and 1 are only linked when page > 1.