Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
All my pages are going to have the same layout except the content will change. If I have an index page which contains all the stuff that's the same from page to page, then use PHP's include() to display the content, will search engines pick up all my content or just the index page?
e.g.:
[code]
<html>
<body>
...stuff that stays the same...
<div id="content"> <?php include($_GET['p'].'.php'); ?> </div>
...more stuff that stays the same...
</body>
</html>
[/code]
(obviously I wouldn't just read p straight from the url)
so the URL of a page called "content" might be:
[url]http://example.com/?p=content[/url]
[QUOTE=aero1444;30565868]All my pages are going to have the same layout except the content will change. If I have an index page which contains all the stuff that's the same from page to page, then use PHP's include() to display the content, will search engines pick up all my content or just the index page?
e.g.:
[code]
<html>
<body>
...stuff that stays the same...
<div id="content"> <?php include($_GET['p'].'.php'); ?> </div>
...more stuff that stays the same...
</body>
</html>
[/code]
(obviously I wouldn't just read p straight from the url)
so the URL of a page called "content" might be:
[url]http://example.com/?p=content[/url][/QUOTE]Let's think logically here...
[QUOTE=aero1444;30566142]What?[/QUOTE]
Search engine will see exactly what you see.
Im just curious but, with websites like megaupload, or even anyhub where you have multiple servers.
How do you synchronize files? or does a server search in its own space and if the file isnt found it then searches in the other servers?
[QUOTE=Richy19;30567951]Im just curious but, with websites like megaupload, or even anyhub where you have multiple servers.
How do you synchronize files? or does a server search in its own space and if the file isnt found it then searches in the other servers?[/QUOTE]Database lookup
[QUOTE=TehWhale;30568138]Database lookup[/QUOTE]
So they both syncronize databases and then when the file is needed it will direct you to the correct server?
[QUOTE=Richy19;30567951]Im just curious but, with websites like megaupload, or even anyhub where you have multiple servers.
How do you synchronize files? or does a server search in its own space and if the file isnt found it then searches in the other servers?[/QUOTE]
[code]
proxy_cache_path /var/cache/nginx/files levels=1:2 keys_zone=files:5000m inactive=24h max_size=100g;
proxy_cache_path /var/cache/nginx/cdn levels=1:2 keys_zone=cdn:500m inactive=24h max_size=100g;
proxy_temp_path /var/cache/nginx/tmp;
server
{
listen 0.0.0.0:80;
server_name cdn.anyhub.net;
location /
{
proxy_pass http://backend.cdn.anyhub.net/;
proxy_cache cdn;
proxy_cache_valid 200 302 24h;
proxy_cache_valid 404 30s;
}
}
server
{
listen 0.0.0.0:80;
server_name ahb.me;
location /
{
rewrite ^/(.*)$ http://f.anyhub.net/$1;
}
}
server
{
listen 0.0.0.0:80;
server_name f.anyhub.net;
server_name *.f.anyhub.net;
error_page 403 http://www.anyhub.net;
error_page 404 http://www.anyhub.net/page/notfound;
rewrite ^/([a-zA-Z0-9_\-]+) /$1;
location = /
{
deny all;
}
location /
{
proxy_pass http://backend.ahb.me/;
proxy_cache files;
proxy_cache_valid 200 302 24h;
proxy_cache_valid 404 30s;
proxy_intercept_errors on;
}
}
[/code]
[editline]20th June 2011[/editline]
and:
[img]http://ahb.me/3dMl[/img]
I don't get it, this:
[code]
$pageVar = 10;
$startRowLimit = ($page * $pageVar) - $pageVar; // returns correct value
$articlesQuery = "SELECT
`ID`,`Title`,`Text`,`Poster`,`Date`,
( SELECT `ID` FROM users WHERE article.`Poster` = users.`Username` )
FROM article WHERE `Visible` = 1 ORDER BY `Date` DESC LIMIT ? , ? ";
$articles = $mysqli->selectAll($articlesQuery, array($startRowLimit, $pageVar));
[/code]
Returns nothing in the website, no errors, no nothing, yet when I do the query in phpMyAdmin is works justt fine?
And it works fine without the LIMIT. So what the hell?
Here's the $mysqli class:
[code]
<?php
class db_conn{
private $connName = "root";
private $connPass = "";
private $connDB = "coop";
private $sql;
private $dbh;
// connects to mysqli database
function db_conn(){
$this->dbh = new PDO("mysql:host=localhost;dbname=$this->connDB", $this->connName, $this->connPass);
}
public function selectAll($query, $params){
$this->sql = $this->dbh->prepare($query);
$this->sql->execute($params);
$result = $this->sql->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
public function selectOne($query, $params){
$this->sql = $this->dbh->prepare($query);
$this->sql->execute($params);
$result = $this->sql->fetch(PDO::FETCH_ASSOC);
return $result;
}
public function updateInsert($query, $params){
$this->sql = $this->dbh->prepare($query);
$this->sql->execute($params);
}
public function rowCount(){
$result = $this->sql->rowCount();
return $result;
}
}
?>
[/code]
Does anyone have a coupon code for Lithium hosting? I heard form someone that FREEWHOIS gives you free domain protection, but it did not work.
[QUOTE=toaster468;30586265]Does anyone have a coupon code for Lithium hosting? I heard form someone that FREEWHOIS gives you free domain protection, but it did not work.[/QUOTE]
that is for Name.com
Should I buy my domain there, or with lithium?
[editline]20th June 2011[/editline]
Also, if someone has a referral link I'd be happy to use it.
[QUOTE=toaster468;30586432]Should I buy my domain there, or with lithium?
[editline]20th June 2011[/editline]
Also, if someone has a referral link I'd be happy to use it.[/QUOTE]
oh, i do
[editline]20th June 2011[/editline]
[url]https://www.lithiumhosting.com/billing/aff.php?aff=195[/url]
Addon domains are not sub domains, correct?
[QUOTE=toaster468;30587145]Addon domains are not sub domains, correct?[/QUOTE]
nope.
Okay, I've heard that id selectors should only be used for things that appear once. But does that depend on the parent?
For instance: Let's say I have a number of boxes, body is their parent. So I would probably use a class selector for the boxes. Now, each box has a title bar thing at the top. Would it be best to use an id or class selector for the title?
[QUOTE=SomeFaggot;30588951]Okay, I've heard that id selectors should only be used for things that appear once. But does that depend on the parent?
For instance: Let's say I have a number of boxes, body is their parent. So I would probably use a class selector for the boxes. Now, each box has a title bar thing at the top. Would it be best to use an id or class selector for the title?[/QUOTE]
Only once ever.
[QUOTE=SomeFaggot;30588951]Okay, I've heard that id selectors should only be used for things that appear once. But does that depend on the parent?
For instance: Let's say I have a number of boxes, body is their parent. So I would probably use a class selector for the boxes. Now, each box has a title bar thing at the top. Would it be best to use an id or class selector for the title?[/QUOTE]
As far as I know IDs are meant to be unique. If you tried to use the javascript "getElementByID" which would it return?
Classes should be used for any style you intend to use more than once.
Does anyone have the link to where I can download the icons FP uses? I forget the website.
silk icons
famfamfam
Why the fuck am I getting a "headers already sent" error when successfully submitting the form on login.php:
login.php:
[php]
<?php
require('includes/dbc.php');
if($_POST['doLogin']){
$username = clean_text($_POST["username"]);
$password = clean_text($_POST["password"]);
$errors = array();
/*** CHECKS ***/
if(strlen($username) > 20){
$errors[] = "Username cannot be longer than 20 characters.";
}
if(strlen($username) < 3){
$errors[] = "Username must be at least 3 characters long.";
}
if(strlen($password) > 80){
$errors[] = "Password cannot be longer than 80 characters.";
}
if(strlen($password) < 5){
$errors[] = "Password must be at least 5 characters long.";
}
/*** END CHECKS ***/
if(empty($errors)){
$check = mysql_query("SELECT * FROM users WHERE username='$username'");
while($row = mysql_fetch_assoc($check)){
$db_uid = $row["id"];
$db_pass = $row["password"];
if($password == $db_pass){
setcookie("uid",$db_uid,time()+99999999);
}else{
$errors[] = "Incorrect username/password.";
}
}
}
}
?>
<html>
<head>
<title></title>
</head>
<body>
<form action='login.php' method='post'>
<table width='200'>
<tr>
<td width='50'>Username: </td>
<td width='150'><input type='text' name='username' maxlength='20' value='<?php echo $username; ?>'></td>
</tr>
<tr>
<td width='50'>Password: </td>
<td width='150'><input type='password' name='password' maxlength='80'></td>
</tr>
<tr>
<td width='50'></td>
<td align='right'><input type='submit' name='doLogin' value='login'></td>
</tr>
<tr>
<td width='50'><a href='login.php'>refresh</a></td>
<td width='150'></td>
</tr>
</table>
</form>
<?php
if(!empty($errors)){
foreach($errors as $error){
echo "<image src='images/exclamation.png'> <font color='grey'>$error</font> <br>";
}
}
echo $_COOKIE["uid"];
?>
</body>
</html>
[/php]
dbc.php:
[php]
<?php
define("HOST", "localhost");
define("USER", "***");
define("PASS", "***");
define("NAME", "***");
$sql_link = mysql_connect(HOST, USER, PASS) or die(mysql_error());
$get_db = mysql_select_db(NAME) or die(mysql_error());
function clean_text($var){
$clean_text = strip_tags(mysql_real_escape_string($var));
return $clean_text;
}
function is_logged_in(){
if(!isset($_COOKIE['uid'])){
header("Location: login.php");
}
}
?>
[/php]
Full error: [b]Warning[/b]: Cannot modify header information - headers already sent by (output started at /***/**/**/*****/includes/dbc.php:1) in /***/***/*/*/****/login.php on line 32
Maybe you got UTC-8 encoding set? That was my problem when I got that error.
[QUOTE=Crhem van der B;30609045]Maybe you got UTC-8 encoding set? That was my problem when I got that error.[/QUOTE]
More specifically, the inclusion of a [url=http://en.wikipedia.org/wiki/Byte_order_mark]byte order mark[/url] will start output. Ensure that you're saving the file without it. Exactly how depends on your editor, but here's how it's done in Notepad++:
[img]http://i.imgur.com/JIog1.png[/img]
Thank you to you both, I would have never figured that out.
Using Sublime Text you won't have this problem :iia:
[QUOTE=TehWhale;30615991]Using Sublime Text you won't have this problem :iia:[/QUOTE]
Sublime makes me feel bad because I use the trail version and it reminds how there is a paid version.
After some time of using Sublime you click the Cancel automaticly 1ms after it appears so you don't even notice it.
[QUOTE=TehWhale;30615991]Using Sublime Text you won't have this problem :iia:[/QUOTE]
I would, but I haven't found a real time ftp file editor "plugin" for it.
----
I have another problem. What I am trying to do is to use the "key" of a user (which is the id of the user set as a cookie) to be used to get other information from the user. I have different rows in my db like email, name, reg date ect and since I don't want those to be stored in cookies I would rather retrieve that data in real time whenever I call it. I'm not sure how to do this since I have tried several ways as to what I thought would work (different functions eg get_username() would echo the username using the id 'key' to obtain it; one function with a parameter eg getinfo('username')).
Here's the code to the one function thing (which is preferred):
[php]
function getinfo($i){
$query = mysql_query("SELECT * FROM users WHERE id='$guid'") or die(mysql_error());
while($row = mysql_fetch_assoc($query)){
$fusername = $row['username'];
$fpassword = $row['password'];
$femail = $row['email'];
$fname = $row['name'];
$frank = $row['rank'];
$fregdate = $row['reg_date'];
}
if($i == "username"){
echo $fusername;
}
}
[/php]
$guid is only existent if they are logged in and is assigned by the 'key' cookie.
The code doesn't display anything.
[QUOTE=alphaspida;30617736]I have another problem. What I am trying to do is to use the "key" of a user (which is the id of the user set as a cookie)[/quote]
You want to store that in the session and not as a plain cookie.
In your code, the $fusername etc. variables are going out of scope from the while loop - so don't use one, just get the values from the first row that fetch_assoc returns (since the id is unique anyway).
Also, don't echo from the function - return the value instead.
What language is youtube made in?
Sorry, you need to Log In to post a reply to this thread.