Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
-snip-
got it working :P
Is it possible to join five different tables via one SQL query and should I then use it, or should I use maybe two or three smaller ones?
[QUOTE=pdkm931;30647281]Is it possible to join five different tables via one SQL query and should I then use it, or should I use maybe two or three smaller ones?[/QUOTE]That's fine
Then it's just a matter of this until I figure out this mindfuck of a SQL string.
for some reason my $posts variable isn't being defined... or something. This is using PHP / CodeIgniter. The query runs fine because if I substiture the actual query into line 3 of the second file, it works perfectly. but as it is I just get a 'posts not defined' error. Any ideas?
[php]
class Blog extends CI_Controller{
public function index(){
$posts = $this->db->query('SELECT post_title, post_text FROM posts ORDER BY post_id DESC');
$this->load->view('blog/blog');
}
}
[/php]
[php]
<h1>Main Blog Page</h1>
<div id="posts">
<?php foreach ($posts->result_array() as $row) { ?>
<div class="post">
<h2><?=$row['post_title'];?></h2>
<p><?=$row['post_text'];?></p>
</div>
<?php } ?>
</div>
[/php]
[editline]23rd June 2011[/editline]
hmm, it looks like the problem is because the $query variable isn't being passed through from my controller file (the top one) to my view file (the bottom one)
Any idea how to make these two work together?
[php]
#
RewriteRule pakabinamos-lubos/(.*)/$ /loader.php?page=lubos&title=$1
#
RewriteRule (.*)/$ /loader.php?page=$1
[/php]
H4Z3Y - shouldn't it be $this->posts?
ohh, i have to put all of my content into a $data array and then pass it through as explained here [url]http://codeigniter.com/user_guide/general/views.html[/url]
[editline]23rd June 2011[/editline]
hmm, still not working [url]http://pastebin.com/7kKMh1ZY[/url]
A while back a few of you were saying that apache was crap and not to use it, what do you tthink of LightTPD?
[QUOTE=H4Z3Y;30655593]ohh, i have to put all of my content into a $data array and then pass it through as explained here [url]http://codeigniter.com/user_guide/general/views.html[/url]
[editline]23rd June 2011[/editline]
hmm, still not working [url]http://pastebin.com/7kKMh1ZY[/url][/QUOTE]
I don't think you understand how scope works.
$data was defined in the function, and only exists in the function; it doesn't exist in the class or anywhere else until you define it there.
[php]
class Blog extends CI_Controller{
public $data;
public function index(){
$this->data['posts'] = $this->db->query('SELECT post_title, post_text FROM posts ORDER BY post_id DESC');
$this->load->view('blog/blog', $data);
}
public function post(){
$this->load->view('blog/post');
}
}
[/php]
[php]
<h1>Main Blog Page</h1>
<div id="posts">
<?php foreach ($classname->data['posts']->result_array() as $row) { ?>
<div class="post">
<h2><?php=$row['post_title'];?></h2>
<p><?php=$row['post_text'];?></p>
</div>
<?php } ?>
</div>
[/php]
[editline]23rd June 2011[/editline]
[url]http://php.net/manual/en/language.variables.scope.php[/url]
[QUOTE=Ac!dL3ak;30657016]I don't think you understand how scope works.
$data was defined in the function, and only exists in the function; it doesn't exist in the class or anywhere else until you define it there.
[php]
class Blog extends CI_Controller{
public $data;
public function index(){
$this->data['posts'] = $this->db->query('SELECT post_title, post_text FROM posts ORDER BY post_id DESC');
$this->load->view('blog/blog', $data);
}
public function post(){
$this->load->view('blog/post');
}
}
[/php]
[php]
<h1>Main Blog Page</h1>
<div id="posts">
<?php foreach ($classname->data['posts']->result_array() as $row) { ?>
<div class="post">
<h2><?php=$row['post_title'];?></h2>
<p><?php=$row['post_text'];?></p>
</div>
<?php } ?>
</div>
[/php]
[editline]23rd June 2011[/editline]
[url]http://php.net/manual/en/language.variables.scope.php[/url][/QUOTE]You also did it wrong
[editline]23rd June 2011[/editline]
But it doesn't matter, I helped him fix it.
[QUOTE=Ac!dL3ak;30657016]I don't think you understand how scope works.
$data was defined in the function, and only exists in the function; it doesn't exist in the class or anywhere else until you define it there.
[php]
class Blog extends CI_Controller{
public $data;
public function index(){
$this->data['posts'] = $this->db->query('SELECT post_title, post_text FROM posts ORDER BY post_id DESC');
$this->load->view('blog/blog', $data);
}
public function post(){
$this->load->view('blog/post');
}
}
[/php]
[php]
<h1>Main Blog Page</h1>
<div id="posts">
<?php foreach ($classname->data['posts']->result_array() as $row) { ?>
<div class="post">
<h2><?php=$row['post_title'];?></h2>
<p><?php=$row['post_text'];?></p>
</div>
<?php } ?>
</div>
[/php]
[editline]23rd June 2011[/editline]
[url]http://php.net/manual/en/language.variables.scope.php[/url][/QUOTE]
you're right, I don't really know what I'm doing, but that wasn't the problem at all.
[QUOTE=Erp;30657066]You also did it wrong
[editline]23rd June 2011[/editline]
But it doesn't matter, I helped him fix it.[/QUOTE]
meh, w/e, you still get it
I was just wondering, can any C# library be used with ASP.Net (with a few changes to the code)
Or do the libraries have to be built specifically for ASP?
[QUOTE=Richy19;30656564]A while back a few of you were saying that apache was crap and not to use it, what do you tthink of LightTPD?[/QUOTE]
nginx has a bigger community.
[QUOTE=Richy19;30656564]A while back a few of you were saying that apache was crap and not to use it, what do you tthink of LightTPD?[/QUOTE]
Better than Apache, decent performance, but I still strongly recommend nginx over it.
There was another one that had better performance than nginx but I forgot the name.
I was messing with DS Linux and I saw that there is a web server application call Boa webserver it looks prety cool, Ill try to set up a website some time soon. The bad part is that i think i have to code the site in nano
[editline]23rd June 2011[/editline]
ds as in for the Nintendo game system.
Is there something like PEMDAS for CSS? Some sort of agreed on order when defining stuff with CSS?
[QUOTE=SomeFaggot;30667117]Is there something like PEMDAS for CSS? Some sort of agreed on order when defining stuff with CSS?[/QUOTE]Alphabetically?
[QUOTE=jaybuz;30666064]There was another one that had better performance than nginx but I forgot the name.[/QUOTE]
[url=http://www.cherokee-project.com/]Cherokee[/url] maybe? At least the the benchmark page says it's faster.
[QUOTE=jaybuz;30666064]There was another one that had better performance than nginx but I forgot the name.[/QUOTE]
[url=http://www.trustleap.com/]G-Wan[/url], we're using it to serve static content. It's a beast, but if you're looking for any control, you have to write C servlets.
[QUOTE=TehWhale;30667149]Alphabetically?[/QUOTE]
That sounds a bit strange for CSS. I understand that it's lenient on the order you put stuff in, but if anybody has an order they like to do stuff in, I'd love to hear it.
Usually I do:
Placement
Size (if it's a block)
Colors (background and/or text)
Text
Other
I either do alphabetically or something exactly like you do. That's weird.
I have a problem
[code]Warning: Cannot modify header information - headers already sent by (output started at /home/zzlawlzz/public_html/testing/header.php:37) in /home/zzlawlzz/public_html/testing/logoff.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at /home/zzlawlzz/public_html/testing/header.php:37) in /home/zzlawlzz/public_html/testing/logoff.php on line 7[/code]
now for some stuff.
header.php
[php]<?php
session_start();
if (isset($_COOKIE['userz']) && isset($_COOKIE['passz'])) {
$_SESSION['username'] = $_COOKIE['userz'];
$_SESSION['password'] = $_COOKIE['passz'];
}
?>
<!doctype html>
<html>
<head>
<!--[if IE]>
<style>
.where {
position:relative;
overflow:visible;
top:-40px;
left:-10px;
}
</style>
<![endif]-->
<link type="text/css" href="style.css" rel="stylesheet">
<title>[Censored]</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21406109-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="logo"><div class="logo">[Censored]</div></div>
<div id="menu"><a href="index">Home</a> / <a href="work">My work</a> / <a href="about">About</a> / <a href="contact">Contact</a></div>[/php]
my logout thing
[php]<?php include('header.php');
if (isset($_SESSION['username'])) {
$_SESSION['username'] = '';
$_SESSION['password'] = '';
setcookie("userz", '', time());
setcookie("passz", '', time());
} else {
echo "You're not even logged in!";
}
?>[/php]
I'm sure some of you will be disgusted by my code which you can point out, but it would be nice so find out what the problem is.
should I just not include the header.php and make it redirect to something else.
[b]EDIT:[/b]
Eh, fixed it using inefficient way
[QUOTE=SomeFaggot;30667451]That sounds a bit strange for CSS. I understand that it's lenient on the order you put stuff in, but if anybody has an order they like to do stuff in, I'd love to hear it.
Usually I do:
Placement
Size (if it's a block)
Colors (background and/or text)
Text
Other[/QUOTE]
Ordering like that doesn't matter. The only place ordering matters is which declaration of a certain style takes priority;
!important > inline styles > <style> tags > external styles
How should I configure my host records to mirror a URL to a sub domain?
I have this, currently, and it doesn't work:
[img]http://localhostr.com/files/B7tUL2z/test.png[/img]
[QUOTE=Within;30668242]How should I configure my host records to mirror a URL to a sub domain?
I have this, currently, and it doesn't work:
[img]http://localhostr.com/files/B7tUL2z/test.png[/img][/QUOTE]
I want to say a CNAME record will work, but I can't remember.
That's weird, test2 works properly (and so does 3 and 4, but I don't want redirect).
I did wait a fair amount of time, cleared my browser's cache and DNS cache but it didn't work when I went to bed.
Ah well, URL Frame it is.
Hmm, didn't use JOIN in the end, but I think it works atleast. But it's not fool proof. But I wonder what you think about my SQL to get a post id, thread title and a username is.
[php]SELECT user.username, thread.title, post.id FROM cat, forum, post, user, thread WHERE user.id = post.user_id AND post.thread_id = thread.id AND thread.forum_id = forum.id AND forum.cat = cat.id AND cat = 1 ORDER BY id DESC[/php]
Shitty, yes. Works, yes. Optimal, dunno.
[QUOTE=Richy19;30659139]I was just wondering, can any C# library be used with ASP.Net (with a few changes to the code)
Or do the libraries have to be built specifically for ASP?[/QUOTE]
Yes, it's all .NET. You don't even need to change the code of a library.
[editline]24th June 2011[/editline]
[QUOTE=StinkyJoe;30667390][url=http://www.trustleap.com/]G-Wan[/url], we're using it to serve static content. It's a beast, but if you're looking for any control, you have to write C servlets.[/QUOTE]
[quote=G-Wan website]
[quote]Result, G-WAN/Linux and C scripts do the job with 5.8 million times[3] less servers than Microsoft IIS + C#:[/quote]
[quote]IIS 7.0/Windows is by far slower than all -despite being part of the kernel.[/quote]
[/quote]
well then explain how stackoverflow only runs on 5 servers (including db servers)
what a terrible attempt at anti-ms propaganda.
Sorry, you need to Log In to post a reply to this thread.