• Web Development Questions That Don't Need Their Own Thread v2
    3,079 replies, posted
[QUOTE=Known Havok;33017233]How would you do the things you could do with cpanel?[/QUOTE] Using SSH and the command line. Alternatively you [i]could[/i] install cPanel on your VPS.
I learnt about a strange bug today to do with IE 8 and 9. Basically if you use a IE6 conditional statements both IE 8 & 9 will hang for a little bit when it gets to it, although not actually processing the information inside. You can see a detailed explanation here: [url]http://webforscher.wordpress.com/2010/05/20/ie-6-slowing-down-ie-8[/url] Although shitty looking I decided to put an empty conditional statement above my CSS and JS because I've already setup my stuff. This somehow "fixes" the problem. Microsoft need to test more! :(
[code] <?php function VisitorIP() { if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $TheIp=$_SERVER['HTTP_X_FORWARDED_FOR']; else $TheIp=$_SERVER['REMOTE_ADDR']; return trim($TheIp); } $errorMessage = ""; if(empty($_POST['name'])) { $errorMessage .= "<li>You forgot to enter a name!</li>"; } if(empty($_POST['content'])) { $errorMessage .= "<li>You forgot to enter some content!</li>"; } $varContent = $_POST['content']; $varName = $_POST['name']; if(empty($errorMessage)) { $db = mysql_connect("localhost","root",""); if(!$db) die("Error connecting to MySQL database."); mysql_select_db("gmod", $db); $sql = "INSERT INTO knowledge (name, content, ip) VALUES (". PrepSQL($varName) . ", " . PrepSQL($varContent) . ", " . VisitorIP() . ")"; mysql_query($sql); header("Location: thank-you.html"); exit(); } // function: PrepSQL() // use stripslashes and mysql_real_escape_string PHP functions // to sanitize a string for use in an SQL query // // also puts single quotes around the string // function PrepSQL($value){ // Stripslashes if(get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote $value = "'" . mysql_real_escape_string($value) . "'"; return($value); } ?> <?php if(!empty($errorMessage)) { echo("<p>There was an error with your form:</p>\n"); echo("<ul>" . $errorMessage . "</ul>\n"); } ?> [/code] I have no idea why this isn't inserting to the database. Any ideas?
Why are you using $_SERVER['HTTP_X_FORWARDED_FOR']? As it can be [b]VERY EASILY[/b] spoofed. Obligatory PDO instead of mysql_*
X-Forwarded-For can be chained, and as mentioned spoofed easily. You should default to using REMOTE_ADDR, and then checking X-Forwarded-For to see if it exists and is valid (Ignore 127.*, 10.*, 192.168.*, etc.) And try checking the return value of your INSERT statement, since the code looks ok to me.
How do I align things vertically? top:50% just doesn't look right.
[QUOTE=toaster468;33023610]How do I align things vertically? top:50% just doesn't look right.[/QUOTE] you also have to set the offset of the element with margin-top:-200px; with 200px being 1/2 of the height
[QUOTE=Ac!dL3ak;33023631]you also have to set the offset of the element with margin-top:-200px; with 200px being 1/2 of the height[/QUOTE] Is there a way I can find the height without going into gimp and measuring the text?
It doesn't matter what script I use, sometimes the images just break :( (it's an image rotation script) script: [php] <?php $images = array('bignipple.png'); header('Location:'.$images[rand(0, (count($images) - 1))]); ?> [/php] error from chrome error report: [quote] Failed to load resource [/quote] example page [url="http://www.ccof.elexar.com/oifyscript"]here[/url] they rarely work at the same time, most of the times at least one of the three breaks. i think it has something to do with apache but i'm not sure and not familiar with apache at all :( this script used to work like a charm when i ran my host on brohoster (switched to lithium).
[QUOTE=toaster468;33023780]Is there a way I can find the height without going into gimp and measuring the text?[/QUOTE]Right click > inspect element > put your cursor over the element in the sourcecode and it'll tell you the dimensions [editline]29th October 2011[/editline] [t]http://i.imgur.com/hVtcg.png[/t]
And in Firebug it's a bit more tucked away: [url=http://dl.dropbox.com/u/386727/ScrnCap/firebug-computed-styles.png][t]http://dl.dropbox.com/u/386727/ScrnCap/firebug-computed-styles.png[/t][/url]
I've had this question for months - how do you link two forum installations to one user table? I know this kind of depends on the different software, so any specifics for mybb/vbulletin or even smf?
[QUOTE=Known Havok;33030077]I've had this question for months - how do you link two forum installations to one user table? I know this kind of depends on the different software, so any specifics for mybb/vbulletin or even smf?[/QUOTE]They use different table structures. It won't happen
Some forums have import functions to bring databases from one type of forum to another, but not meant for linking two forums.
[QUOTE=TehWhale;33030088]They use different table structures. It won't happen[/QUOTE] Well he could rewrite it all
[QUOTE=mobrockers2;33031543]Well he could rewrite it all[/QUOTE]why even suggest this at all
[QUOTE=TehWhale;33031597]why even suggest this at all[/QUOTE] why not
[php] <?php $mysqli = new mysqli($config["db_location"], $config["db_username"], $config["db_password"], $config["db_name"]) or die(mysqli_error()); $sql = "SELECT id, name, type, content, date FROM knowledge ORDER BY id DESC LIMIT 0, 5"; if(isset($_GET['all'])){ $sql = "SELECT id, name, type, content, date FROM knowledge ORDER BY id DESC"; } if(isset($_GET['id'])) { $page = (isset($_GET['id'])) ? $_GET['id'] : "8"; $sql = "SELECT id, name, type, content, date FROM knowledge WHERE id='$page'"; $result = $mysqli->query($sql) or die("This knowledge piece doesn't exist!"); if($result){ $row2 = $result->fetch_object(); } } $result = $mysqli->query($sql) or die(mysqli_error()); ?> <h2>Welcome to the <span class="logo inline">gmdb</span>, the gmod knowledge database!</h2> To get started, choose a page from the side or look at new knowledge pieces below. <br /><br /><br /> <?php if($result){ while($row = $result->fetch_object()){ echo "<div class=\"item\"> <h4><span>Category:</span> {$row->type} <span class=\"sep\">/</span> <span>ID #</span>{$row->id}</h4> {$row->content} <div class=\"stats\"> <h2 class=\"ribbonR name gradient\">{$row->name}</h2> <h2 class=\"ribbonR date gradient\">{$row->date}</h2> </div> </div> "; } } elseif(isset($_GET['id'])){ echo " <div class=\"item\"> <h4><span>Category:</span> {$row2->type} <span class=\"sep\">/</span> ID #{$row2->id}</h4> {$row2->content} <div class=\"stats\"> <h2 class=\"ribbonR name gradient\">{$row2->name}</h2> <h2 class=\"ribbonR date gradient\">{$row2->date}</h2> </div> </div> "; } if ($mysqli->num_rows($result) < 1){ echo "Sorry this ID doesn't exist."; } ?> [/php] This is the shittest complication of code I've made. I need it to return the sorry ID doesn't exist message if it doesn't actually exist, but I can't get it right. Help please.
[QUOTE=RusselG;33037266] This is the shittest complication of code I've made. I need it to return the sorry ID doesn't exist message if it doesn't actually exist, but I can't get it right. Help please.[/QUOTE] Talk about making things harder for yourself. General rule of thumb - if you're using "echo" statements to build your HTML, you're doing things wrong. [php]<?php $mysqli = new mysqli($config["db_location"], $config["db_username"], $config["db_password"], $config["db_name"]) or die(mysqli_error()); $sql = "SELECT id, name, type, content, date FROM knowledge ORDER BY id DESC LIMIT 0, 5"; if(isset($_GET['all'])){ $sql = "SELECT id, name, type, content, date FROM knowledge ORDER BY id DESC"; } if(isset($_GET['id'])) { $page = (isset($_GET['id'])) ? $_GET['id'] : "8"; $sql = "SELECT id, name, type, content, date FROM knowledge WHERE id='$page'"; $result = $mysqli->query($sql) or die("This knowledge piece doesn't exist!"); if($result){ $row2 = $result->fetch_object(); } } $result = $mysqli->query($sql) or die(mysqli_error()); ?> <h2>Welcome to the <span class="logo inline">gmdb</span>, the gmod knowledge database!</h2> <p> To get started, choose a page from the side or look at new knowledge pieces below. </p> <?php if($result): ?> <?php while($row = $result->fetch_object()): ?> <div class="item"> <h4><span>Category:</span><?php echo {$row->type} ?><span class="sep">/</span> <span>ID #</span><?php echo {$row->id} ?></h4> <?php echo {$row->content} ?> <div class="stats"> <h2 class="ribbonR name gradient"><?php echo {$row->name} ?></h2> <h2 class="ribbonR date gradient"><?php echo {$row->date} ?></h2> </div> </div> <?php endwhile ?> <?php elseif(isset($_GET['id'])): ?> <div class="item\"> <h4><span>Category:</span><?php echo {$row2->type} ?><span class="sep">/</span> ID #<?php echo {$row2->id} ?></h4> <?php echo {$row2->content} ?> <div class="stats"> <h2 class="ribbonR name gradient"><?php echo {$row2->name} ?></h2> <h2 class="ribbonR date gradient"><?php echo {$row2->date} ?></h2> </div> </div> <?php endif ?> <?php if($mysqli->num_rows($result) < 1): ?> Sorry, this ID doesn't exist. <?php endif ?>[/php] It barely costs anything at all to break in and out of a PHP block, make use of that.
[QUOTE=TehWhale;33031597]why even suggest this at all[/QUOTE] I'm not suggesting he do that.
[QUOTE=StinkyJoe;33037712]Talk about making things harder for yourself. General rule of thumb - if you're using "echo" statements to build your HTML, you're doing things wrong. [php]<?php $mysqli = new mysqli($config["db_location"], $config["db_username"], $config["db_password"], $config["db_name"]) or die(mysqli_error()); $sql = "SELECT id, name, type, content, date FROM knowledge ORDER BY id DESC LIMIT 0, 5"; if(isset($_GET['all'])){ $sql = "SELECT id, name, type, content, date FROM knowledge ORDER BY id DESC"; } if(isset($_GET['id'])) { $page = (isset($_GET['id'])) ? $_GET['id'] : "8"; $sql = "SELECT id, name, type, content, date FROM knowledge WHERE id='$page'"; $result = $mysqli->query($sql) or die("This knowledge piece doesn't exist!"); if($result){ $row2 = $result->fetch_object(); } } $result = $mysqli->query($sql) or die(mysqli_error()); ?> <h2>Welcome to the <span class="logo inline">gmdb</span>, the gmod knowledge database!</h2> <p> To get started, choose a page from the side or look at new knowledge pieces below. </p> <?php if($result): ?> <?php while($row = $result->fetch_object()): ?> <div class="item"> <h4><span>Category:</span><?php echo {$row->type} ?><span class="sep">/</span> <span>ID #</span><?php echo {$row->id} ?></h4> <?php echo {$row->content} ?> <div class="stats"> <h2 class="ribbonR name gradient"><?php echo {$row->name} ?></h2> <h2 class="ribbonR date gradient"><?php echo {$row->date} ?></h2> </div> </div> <?php endwhile ?> <?php elseif(isset($_GET['id'])): ?> <div class="item\"> <h4><span>Category:</span><?php echo {$row2->type} ?><span class="sep">/</span> ID #<?php echo {$row2->id} ?></h4> <?php echo {$row2->content} ?> <div class="stats"> <h2 class="ribbonR name gradient"><?php echo {$row2->name} ?></h2> <h2 class="ribbonR date gradient"><?php echo {$row2->date} ?></h2> </div> </div> <?php endif ?> <?php if($mysqli->num_rows($result) < 1): ?> Sorry, this ID doesn't exist. <?php endif ?>[/php] It barely costs anything at all to break in and out of a PHP block, make use of that.[/QUOTE] Do you think it is possibly more efficient since all that HTML doesn't have go through PHP's echo method? It's funny how people don't use PHP the way it was designed.
[QUOTE=jaybuz;33038396]Do you think it is possibly more efficient since all that HTML doesn't have go through PHP's echo method? It's funny how people don't use PHP the way it was designed.[/QUOTE] Between calling echo or jumping in and out of the PHP interpreter, it's likely there's little gain in either direction. The things is, using echo makes everything much harder to manage - no syntax highlighting, the need to escape certain characters, much harder to structure and re-factor, and much more error-prone.
Well, thanks anyway StinkyJoe. Using yours now, and no errors! Had to clean up some tiny mistakes, but thanks!
Hi guys, I don't know anything about PHP so I'll ask here: I'd like to make a masterserver for my game in PHP. The script / program should only have two functions: - Add or update a server to the list: getting the name and the public ip of the server. - Send the serverlist to someone who requests it. It should save: server-name, timeout and ip. The script should delete all records that are older than one minute, so a running server has to re-register itself at least once every minute. Do you guys know any tutorials about something like this? Also, how long would this take approximately ?
What is the following even called? making something like this [url]http://Hamburger.com?link=toiadsf&hugs=49[/url] into this [url]http://Hamburger.com/toiadsf/49[/url] It's difficult to google these things as difficult as they are to describe
[QUOTE=Sprite;33052526]What is the following even called? making something like this [url]http://Hamburger.com?link=toiadsf&hugs=49[/url] into this [url]http://Hamburger.com/toiadsf/49[/url] It's difficult to google these things as difficult as they are to describe[/QUOTE] mod_rewrite ?
[QUOTE=Sprite;33052526]What is the following even called? making something like this [url]http://Hamburger.com?link=toiadsf&hugs=49[/url] into this [url]http://Hamburger.com/toiadsf/49[/url] It's difficult to google these things as difficult as they are to describe[/QUOTE] From my website: [code] Options +FollowSymLinks -Indexes RewriteEngine On RewriteRule ^login/$ login.php RewriteRule ^logout/$ logout.php RewriteRule ^register/$ register.php RewriteRule ^img/show/(.+)$ image_show.php?p=$1 [/code] You need the mod_rewrite module and then put something like this in your .htaccess file on the main folder.
[QUOTE=Felheart;33048518]Hi guys, I don't know anything about PHP so I'll ask here: I'd like to make a masterserver for my game in PHP. The script / program should only have two functions: - Add or update a server to the list: getting the name and the public ip of the server. - Send the serverlist to someone who requests it. It should save: server-name, timeout and ip. The script should delete all records that are older than one minute, so a running server has to re-register itself at least once every minute. Do you guys know any tutorials about something like this? Also, how long would this take approximately ?[/QUOTE] Sounds relatively simple, but it depends on: How do you want the servers to communicate with your PHP-"master server" ? HTTP? Sockets? SOAP? How do you want your clients to communicate? How long it will take for you to make, i don't know :-)
For the last few hours, I've been playing around with Sinatra and it seems wonderful for small utilities. I'm currently looking for the best platform for a project I'm about to start on and I'm considering Sinatra. However, my project is going to be rather large. Would Sinatra be a good choice for larger projects or should I turn to Rails?
Okay so I have a question for anyone who can help me, we just got an assignment in my HTML class about tables, we just learned about them and I can't get something to work. Here's a visual to help give you an idea and better describe: [T]http://i.imgur.com/UgzaZ.png[/T] So basically what I need is for the 30th, 31st at the beginning and the 1, 2, 3, 4, 5th at the end to have no white/yellow fill, just match the background of the page. To give color to the columns I used: [CODE]<colgroup> <col span="1" class="yellow"></col> <col span="4" class="white"></col> <col span="2" class="yellow"></col> </colgroup>[/CODE] With that in mind I thought I could simply apply another class with: [CODE]background-color:transparent[/CODE] To the individual <td> tags with the specific date of the background I want to remove, however it's not working. Am I going about this the complete wrong way? Feel free to laugh at me, I just want to figure this out :v: Also external css is a requirement, it also has to be HTML strict validated.
Sorry, you need to Log In to post a reply to this thread.