• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
too bad renewing .me domains are really expensive compared to .com buying .me domains for 2 years is the same price as getting 1 for free and renewing it for 1 year. [url]https://www.namecheap.com/domains.aspx[/url]
[QUOTE=jung3o;47344088]too bad renewing .me domains are really expensive compared to .com buying .me domains for 2 years is the same price as getting 1 for free and renewing it for 1 year. [url]https://www.namecheap.com/domains.aspx[/url][/QUOTE] I'm quite sure those prices are yearly... So if I buy a domain for 2 years, I pay twice the fee that is listed there. All domains get cheaper by a few cents, the longer you buy it for, so why would anyone buy 1 year domains if it gets cheaper?
[QUOTE=jung3o;47344088]too bad renewing .me domains are really expensive compared to .com buying .me domains for 2 years is the same price as getting 1 for free and renewing it for 1 year. [url]https://www.namecheap.com/domains.aspx[/url][/QUOTE] $1 or $2 a month isn't expensive anyhow Get a job
Never mind. Apparently node.js doesn't support php. Anyway to get it to work together?
[QUOTE=:0;47358591]Never mind. Apparently node.js doesn't support php. Anyway to get it to work together?[/QUOTE] Node.js support PHP? What do you mean? If you want them to work together you can use sockets, just like any other languages communicate with eachother.
I didn't know that it's possible for node.js. Is there like a basic tutorial on how to set it up by any chance? I mean by using sockets. [img]https://imagicon.info/cat/6-4/1.gif[/img]
[QUOTE=ragortue;47361541]I didn't know that it's possible for node.js. Is there like a basic tutorial on how to set it up by any chance? I mean by using sockets. [img]https://imagicon.info/cat/6-4/1.gif[/img][/QUOTE] At one point in my life, when i was severly uneducated in the topic of web development, i had done this (for a chat application, if you must know... Yes, it was horrendous). I really do not reccomend doing it, primarily for latency issues. However, if you still feel like doing this, and you're not keen on rebuilding anything... This can be done. Sending messages from PHP to NodeJS would be quite simple, although there are a few ways to do it. 1. You could use sockets. This is the best option as it requires no extra layers inbetween the application and the networking. 2. You could use Redis. Redis is a memory cache system, just like memcached. However this also supports broadcasting messages, so you can set up PHP to broadcast a message to NodeJS like this. 3. You could use HTTP requests. This is by far the slowest and worst method of doing it, simply because HTTP is an added layer of networking, and it doesn't really support cross-communication unless both parts are a web server. Sending messages from NodeJS to PHP is an entirely different story, because PHP doesn't run like a daemon, it is only invoked by the webserver to render a page. This means that you are limited to either making NodeJS spawn PHP as a [URL="https://nodejs.org/api/child_process.html"]child_process[/URL], or sending an HTTP request to the webserver PHP is running on. [editline]something[/editline] [QUOTE=Rocket;47359288]-snip- If you really want to, [url]https://www.npmjs.com/package/node-php[/url] [/QUOTE] As said i've "combined" NodeJS and PHP before, and that was using this to spawn php as a child_process. Doing this, i had to modify node-php to forward the "real" client ip address when behind a reverse proxy such as cloudflare. I tried making a pull request to the author of this module, but it seems to be an inactive or abandoned project. See [URL="https://github.com/mkschreder/node-php/pull/1"]this[/URL].
[QUOTE=:0;47358591]Never mind. Apparently node.js doesn't support php. Anyway to get it to work together?[/QUOTE] What'd you think the "js" in "node.js" stood for?
I literally have no idea what the hell I'm doing when it comes to web development. I have a python script I've written that acts as a fake game client and requests server info from a master server. It then takes this information, gets all the player counts from all servers and adds them up. It does this for 3 separate games so I can compare player counts. All I want the website to do is take those numbers from my computer and put it in big fucking letters on the site that says "X (Game Name) players online" What's the best way to go about doing that?
Trying to learn Wordpress and use Bootstrap at the same time. How can I modify the style.css? Is there something weird you have to do? Nothing I do seems to work. In my header.php I have [CODE] <link rel="stylesheet" type="text/css" href="style.css"> <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet">[/CODE] the style.css has stuff in it that should obviously change color, such as setting the text color, but it just won't work. Am I doing something wrong here?
[QUOTE=Over-Run;47364796]Trying to learn Wordpress and use Bootstrap at the same time. How can I modify the style.css? Is there something weird you have to do? Nothing I do seems to work. In my header.php I have [CODE] <link rel="stylesheet" type="text/css" href="style.css"> <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet">[/CODE] the style.css has stuff in it that should obviously change color, such as setting the text color, but it just won't work. Am I doing something wrong here?[/QUOTE] Disable browser cache Enable Cloudflare Developer mode (if you use Cloudflare). Also, don't edit bootstrap.css, create your own CSS file with your own settings that override bootstrap.css
how do i design a website do i learn html and go from there?
[QUOTE=thefreemann;47365160]how do i design a website do i learn html and go from there?[/QUOTE] into webdesign [url]http://www.codecademy.com/en/tracks/web[/url]
Don't have much experience with making classes, what type of things generally go in constructor functions? I can't think of anything that really needs to go into it, since most of the initialization will go in my class::Init(); function.
[QUOTE=Th3applek1d;47365632]Don't have much experience with making classes, what type of things generally go in constructor functions? I can't think of anything that really needs to go into it, since most of the initialization will go in my class::Init(); function.[/QUOTE] The constructor is the "init" function... PHP Example: [code] class Class { /** * Points to the connection object * */ private $con; public function __construct($con = false) { $this->con = $con; } public function hasCon() { if($this->con) { return true; } } } $connection = connectToSomething(); $class = new Class($connection); echo $class->hasCon(); // true $anotherClass = new Class(); echo $class->hasCon(); // false [/code]
So variables before your constructor are for arguments to supply when creating the class? Also, in the construct function in your example, $con is only false if it is not set correct? And could I initialize a mysqli connection in the construct class? I assume this would work? I wasn't entirely sure how to supply arguments to a new class so I was just going to have database init and stuff in a separate function. [code] class Class{ private $hostname = 'localhost'; // Defaults to localhost if not supplied? private $username; private $password; private $dbname; private $port = 3306; // Defaults to 3306 if not supplied? // MySQLi Object private $db; public function __construct($hostname, $username, $password, $dbname, $port{ $this->db = new mysqli($hostname,$username,$password,$dbname,$port); if ($this->db->connect_error) { die('Connect Error (' . $this->db->connect_errno . ') '. $this->db->connect_error); } } } new Class('localhost','root','password', 'mysql', '3306'); [/code]
[QUOTE=Th3applek1d;47365875]So variables before your constructor are for arguments to supply when creating the class? Also, in the construct function in your example, $con is only false if it is not set correct? And could I initialize a mysqli connection in the construct class? I assume this would work? I wasn't entirely sure how to supply arguments to a new class so I was just going to have database init and stuff in a separate function. [code] class Class{ private $hostname = 'localhost'; // Defaults to localhost if not supplied? private $username; private $password; private $dbname; private $port = 3306; // Defaults to 3306 if not supplied? // MySQLi Object private $db; public function __construct($hostname, $username, $password, $dbname, $port{ $this->db = new mysqli($hostname,$username,$password,$dbname,$port); if ($this->db->connect_error) { die('Connect Error (' . $this->db->connect_errno . ') '. $this->db->connect_error); } } } new Class('localhost','root','password', 'mysql', '3306'); [/code][/QUOTE] You got it partially right, the variables before the constructor can be anything you want really, and you can place them wherever you want as well but it's cleaner to place them up top. One good thing I've learned from moving from PHP to Javascript is that it's always easier to define options as an object (If you have more than 2-3 that is), and in your case it'd look something like this: [code] <?php class Class { /** * Points to the DB connection object * @var Object */ private $mysqli; /** * Holds the passed argument options * @var Array */ public $opts; /** * Class constructor * @param array || boolean */ public function __construct($opts = false) { $this->opts = ($opts) ? $opts : die('You need to specify options'); $this->mysqli = $this->connect(); } /** * Creates a new connection to the DB. * @return Object */ public function connect() { $mysqli = new mysqli($this->opts['hostname'], $this->opts['username'], $this->opts['password'], $this->opts['dbname'], $this->opts['port']); if ($this->db->connect_error) { die('Connect Error (' . $this->db->connect_errno . ') '. $this->db->connect_error); } else { return $mysqli; } } /** * Selects all items from DB * @return array */ public function selectAll() { return $this->mysqli->query('SELECT * FROM `table`'); } } $opts = [ 'hostname' => 'localhost', 'username' => 'root', 'password' => 'password', 'dbname' => 'mysql', 'port' => 3306 ]; $class = new Class($opts); $items = $class->selectAll(); var_dump($items); ?> [/code]
[QUOTE=Svenskunganka;47366089]You got it partially right, the variables before the constructor can be anything you want really, and you can place them wherever you want as well but it's cleaner to place them up top. One good thing I've learned from moving from PHP to Javascript is that it's always easier to define options as an object (If you have more than 2-3 that is), and in your case it'd look something like this: [/QUOTE] That looks a lot better, and logically makes a lot more sense. Thanks!
[QUOTE=Th3applek1d;47366106]That looks a lot better, and logically makes a lot more sense. Thanks![/QUOTE] I updated the code a little, it was at least 5 months since I last wrote PHP :P
[QUOTE=Cyberuben;47364985]Disable browser cache Enable Cloudflare Developer mode (if you use Cloudflare). Also, don't edit bootstrap.css, create your own CSS file with your own settings that override bootstrap.css[/QUOTE] But how can I use bootstrap if I have to make my own css file?
[QUOTE=Over-Run;47367204]But how can I use bootstrap if I have to make my own css file?[/QUOTE] First include bootstrap.css (or bootstrap.min.css if you're in production), then on the next line, include your own style.css. Doing it like this makes any value in style.css override what is in bootstrap.css without any need for dumb stuff like !important.
Yeah I have it working now thanks :) Another problem, hopefully an easy fix. Basically I have a navigation bar along the top of my site, and I want to have a full screen image, and have the navigation menu be on top of that image, with the background of the navigation menu being transparent. How can I do this? Right now the navigation menu pushes the full screen image down. EDIT All good I got it now
[QUOTE=Cyberuben;47363141]What'd you think the "js" in "node.js" stood for?[/QUOTE] php
So I'm using Bootstrap and wondering how can I make text resize inside a div when the screen is small? I have a div with text in it, but when I resize the browser, the text stays the same size and gets pushed out of the div. How can I make it stay inside the div and resize correctly?
[QUOTE=Over-Run;47370566]So I'm using Bootstrap and wondering how can I make text resize inside a div when the screen is small? I have a div with text in it, but when I resize the browser, the text stays the same size and gets pushed out of the div. How can I make it stay inside the div and resize correctly?[/QUOTE] media queries and for modern browsers css vw and vh size units.
Are prepared statements a must for performance?
[QUOTE=Th3applek1d;47372288]Are prepared statements a must for performance?[/QUOTE] I don't think they have much impact on performance, but they escape all user input. (I assume you're talking about SQL here)
[QUOTE=Miljaker;47370588]media queries and for modern browsers css vw and vh size units.[/QUOTE] Do you have any examples? I have [CODE]@media(min-width:768px) { .fabrics{ font-size: 11px; }[/CODE] But it doesn't work. and I want it to stay inside the div it's in and not go outside of it
[QUOTE=Over-Run;47372991]Do you have any examples? I have [CODE]@media(min-width:768px) { .fabrics{ font-size: 11px; }[/CODE] But it doesn't work. and I want it to stay inside the div it's in and not go outside of it[/QUOTE] here's some i have been working on today, i'll comment them a bit [code] /* activate on screens below 550 width */ @media screen and (max-width: 550px) { .s2,.s3,.s3,.s4,.s5,.s6,.s6,.s7,.s8,.s9,.s10,.s11{ width:calc(100% - 0.4em); height:auto !important; } .s1{ width:calc(50% - 0.4em); } } /* activate on screens below between 551 and 800 width */ @media screen and (min-width: 551px) and (max-width:800px) { .s7,.s8,.s9,.s10,.s11{ } .s4,.s5,.s6,.s2,.s3{ } .s1{ } } /* activate on screens below between 801 and 960 width */ @media screen and (min-width: 801px) and (max-width:960px) { .s9,.s10,.s11,.s12{ } .s5,.s6,.s7{ } .s4{} .s8{} } [/code] you have to choose the media type (screen, printer page etc) for it to select a media context it really helps to hop on to chrome and enable dev tools, which shows you the media query breakpoints visually: [t]http://a.pomf.se/brzbui.png[/t]
Hey, Is it bad practice to keep user- and admin-code (javascript) in one .js file? Of course there are server-side checks for the admin-functions, so it can't be abused. It just feels wrong putting it into another .js file, since they both need the same helper-functions.
Sorry, you need to Log In to post a reply to this thread.