• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
The problem is you are missing the colon (I think). I would write it as [code] $stmt->execute(array(':username' => $username,':password' => $password)); [/code] At least that's how all of the documentation shows it. Also somewhat irrelevant but you might want to store a password hash, rather than a plaintext password. The new [url=http://www.php.net/manual/en/ref.password.php]password hashing functions[/url] are really easy to use and (I'm told) they make things more secure if you only store the hash.
[QUOTE=jung3o;41244748]check if the sql works on the mysql database? [editline]29th June 2013[/editline] you have to set fetch right after you prepare btw[/QUOTE] Not exactly, you can set the fetch mode as an argument to 'fetchAll'. [editline]30th June 2013[/editline] [QUOTE=Rayjingstorm;41245066]The problem is you are missing the colon (I think). I would write it as [code] $stmt->execute(array(':username' => $username,':password' => $password)); [/code] At least that's how all of the documentation shows it. Also somewhat irrelevant but you might want to store a password hash, rather than a plaintext password. The new [URL="http://www.php.net/manual/en/ref.password.php"]password hashing functions[/URL] are really easy to use and (I'm told) they make things more secure if you only store the hash.[/QUOTE] PDO works whether you have the colons or not. [editline]30th June 2013[/editline] [QUOTE=Coment;41244808]Also, remove the single quotes from :username and :password; PDO automatically adds them[/QUOTE] Don't let the disagree on his post fool you, you do need to remove the single quotes from your query. EDIT: Just for further clarification, PDO doesn't exactly add them, prepared statements don't work the same way as traditional queries that you got used to in the old mysql_query function. When you prepare a statement, that gets communicated to the SQL database and the database parses the statement (with the placeholders), compiles it, and optimizes it. Later on when PDO executes the statement, it sends just the parameters and what placeholder they're associated with. This means that nothing gets escaped because the database knows that they are just parameters, and it will not contain any pieces to a query.
What would cause Google Graphs to display like this? [img]https://dl.dropbox.com/u/1439918/Pics/2013-06-30_00-05-58.png[/img] It typically hides the percentages of slices it can't fully display, but something's going funky. I have another pie graph and table on the page that work fine.
What's the best way to make note of a user's location when they are required to login? I want to allow users to bookmark protected pages, but if they then access these pages before logging in they will need to be redirected to the login page. At this point I want to redirect them [i]back[/i] to where they started upon a successful login, but I'm not sure the best method. So far I've considered the HTTP_REFERER field, a url variable, or through _SESSION. The first wouldn't work if another site referred the user, the second requires escaping, and the last seems odd as it really isn't a state that needs to be remembered for the user. I'm probably over-thinking this but what do you recommend?
Fixed it.
[QUOTE=MarcoPixel;41244097]How can i fix this? [IMG]http://i.imgur.com/zw60qbV.png[/IMG] CSS: [CODE] .sub { background-color: #FFF; height: 50px; width: 100%; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-bottom:2px solid #E0E0E0; } .searchinput { box-sizing:border-border; margin-top: 10px; margin-left: 10px; margin-right: 10px; width: 100%; padding-right: 10px; border-width:0; display:block; } [/CODE] HTML: [CODE] <div class="sub"> <form action="http://www.google.at/search"> <input class="searchinput" type="search" name="q" x-webkit-speech speech required onspeechchange="startSearch" size=100> </form> </div> [/CODE] I still want to keep it responsive and without stupid @media hacks.[/QUOTE] try [code] box-sizing: border-box; [/code] on the searchinput or you could do: [code] width: calc(100% - 20px) [/code] but that is not crossbrowser compatible.
[QUOTE=Rayjingstorm;41246821]What's the best way to make note of a user's location when they are required to login? I want to allow users to bookmark protected pages, but if they then access these pages before logging in they will need to be redirected to the login page. At this point I want to redirect them [i]back[/i] to where they started upon a successful login, but I'm not sure the best method. So far I've considered the HTTP_REFERER field, a url variable, or through _SESSION. The first wouldn't work if another site referred the user, the second requires escaping, and the last seems odd as it really isn't a state that needs to be remembered for the user. I'm probably over-thinking this but what do you recommend?[/QUOTE] It sounds like you need something like [I]$_SERVER['REQUEST_URI'][/I] somesite.org/somepath.ext It will get somepath.ext So your pages can have [I]$_SESSION['url'] = $_SERVER['REQUEST_URI'];[/I] And then your login pages [CODE] $url = $_SESSION['url']; if(doLogin = true){ //code(); header("Location: yoursite.com" . $url); exit; } [/CODE] That should do it
[QUOTE=Rayjingstorm;41246821]What's the best way to make note of a user's location when they are required to login? I want to allow users to bookmark protected pages, but if they then access these pages before logging in they will need to be redirected to the login page. At this point I want to redirect them [i]back[/i] to where they started upon a successful login, but I'm not sure the best method. So far I've considered the HTTP_REFERER field, a url variable, or through _SESSION. The first wouldn't work if another site referred the user, the second requires escaping, and the last seems odd as it really isn't a state that needs to be remembered for the user. I'm probably over-thinking this but what do you recommend?[/QUOTE] You could store their current location in the session right before redirecting them to the login page. EDIT: okay, rate me late please.
[QUOTE=dastiii;41249259]You could store their current location in the session right before redirecting them to the login page. EDIT: okay, rate me late please.[/QUOTE] I feel your explanation was a little bit better than mine. (Apart from the lacking code)
Is it possible to have multiple Joomla installations and having only one admin panel for them?
Before I go ahead and make this, is there anything I should change? [img_thumb]https://dl.dropboxusercontent.com/u/33714868/%21display/folio%20plan.jpg[/img_thumb]
I need to allow file uploads which are tied to a given page and user account (each user has many pages, each with a list of files). I basically want a dressed up directory listing with access controls, but I'm not sure if I want to store the files in the filesystem and just reference them in the database, or if I want to actually store them as blobs in the database. What do you guys think? If I store them in the filesystem I feel I will end up making a copy of the entire site database structure to keep the files organized, but if I store them in the database I won't be able to access the files any other way (although this may be a bit more secure anyway).
[QUOTE=Rayjingstorm;41265974]I need to allow file uploads which are tied to a given page and user account (each user has many pages, each with a list of files). I basically want a dressed up directory listing with access controls, but I'm not sure if I want to store the files in the filesystem and just reference them in the database, or if I want to actually store them as blobs in the database. What do you guys think? If I store them in the filesystem I feel I will end up making a copy of the entire site database structure to keep the files organized, but if I store them in the database I won't be able to access the files any other way (although this may be a bit more secure anyway).[/QUOTE] I think your best bet would be to make a directory where all your files are going to be uploaded, and then block any access from the public using .htaccess, then this way you'll only be able to download the files using a PHP script which in turn will check if the user logged in has access to the file he's trying to download and proceed accordingly.
[QUOTE=andyah;41266057]I think your best bet would be to make a directory where all your files are going to be uploaded, and then block any access from the public using .htaccess, then this way you'll only be able to download the files using a PHP script which in turn will check if the user logged in has access to the file he's trying to download and proceed accordingly.[/QUOTE] This sounds good, although I will probably have to create sub-directories for each page to avoid naming conflicts. Come to think of it there really doesn't need to be a separated db table, as I really just need to have one directory per user-page, and then I can dynamically create a directory listing using php IO functions. Also this would require PHP in the middle, so I could easily authenticate.
-Snips-
[QUOTE=commander204;41249062]try [code] box-sizing: border-box; [/code] on the searchinput or you could do: [code] width: calc(100% - 20px) [/code] but that is not crossbrowser compatible.[/QUOTE] Thanks, fixed it. Used it for a chrome new tab page which im using for personal use. [T]http://i.imgur.com/u9j8DeQ.png[/T]
If I wanted to make a super duper fast porn video site in what technologies should I make it?
[QUOTE=asantos3;41299177]If I wanted to make a super duper fast porn video site in what technologies should I make it?[/QUOTE] Ideally, it would come down to having powerful hardware and a fast connection if you are streaming videos / serving a large number of images. I'd likely roll with some form of elasticsearch and node.js and nginx in the front to serve static files. Elasticsearch is awesome as a search engine and scales much more appropriately than MySQL ever would. As for when you hit the capacity of a single machine, put something like HAProxy in front of multiple machines and distribute the load and you are golden. Not only would you be able to distribute it across multiple machines, but node.js, unlike PHP, will scale across all of the cores by using the cluster module. Anyways, just my 2c from working on a project that gets ~2 billion clicks a day.
[QUOTE=andersonmat;41299659]Ideally, it would come down to having powerful hardware and a fast connection if you are streaming videos / serving a large number of images. I'd likely roll with some form of elasticsearch and node.js and nginx in the front to serve static files. Elasticsearch is awesome as a search engine and scales much more appropriately than MySQL ever would. As for when you hit the capacity of a single machine, put something like HAProxy in front of multiple machines and distribute the load and you are golden. Not only would you be able to distribute it across multiple machines, but node.js, unlike PHP, will scale across all of the cores by using the cluster module. Anyways, just my 2c from working on a project that gets ~2 billion clicks a day.[/QUOTE] I hate PHP, but saying that PHP can't scale across multiple cores is just plain wrong.
[QUOTE=KmartSqrl;41299957]I hate PHP, but saying that PHP can't scale across multiple cores is just plain wrong.[/QUOTE] Let me rephrase that then: yes, it will run on all cores, but it is not fundamentally designed to do so as it relies upon whatever is spawning the process. Apache or whatever parent you use will inevitably spawn child processes to handle requests but in the transactional model of HTTP, they are essentially used once and then their resources no longer exist. The reason I suggested something else would be the fact that you could share resources between requests. Sure, PHP supports pcntl_fork, but in any "application" environment it doesn't really serve a purpose with traditional client interaction. It may have a use say, running in a screen, where it runs as a daemon to process x, y, or z.
so in my mysql database I am storing days and hours open in one field, called "days", the data is stored in the following format: [Monday:9:17[Tuesday:9:17[Wednesday:10:18[ as you may've guessed, it goes: [Day:From:Till and brackets are just seperators for PHP to distinguish how many days is there. I've been thinking all day what query would be but I could not figure out, so basically I need to get current date and time using PHP: date(l); // Day in full text representation. date(G); // current hour in 24 hour format. So basically I need a query which in simple english would sound like: Select all from businessdetails where column date contains [current date] and :#:# numbers to be less than current hour and greater than current hour. Help? My brain is melting by now.
[QUOTE=arleitiss;41300327]so in my mysql database I am storing days and hours open in one field, called "days", the data is stored in the following format: [Monday:9:17[Tuesday:9:17[Wednesday:10:18[ as you may've guessed, it goes: [Day:From:Till and brackets are just seperators for PHP to distinguish how many days is there. I've been thinking all day what query would be but I could not figure out, so basically I need to get current date and time using PHP: date(l); // Day in full text representation. date(G); // current hour in 24 hour format. So basically I need a query which in simple english would sound like: Select all from businessdetails where column date contains [current date] and :#:# numbers to be less than current hour and greater than current hour. Help? My brain is melting by now.[/QUOTE] You may be able to do a LIKE query across the values to match the day and then process the rest of the rows manually by using PHP's split() method to compare the hours. I am not aware of anything that would allow you to analyze each time value as well as the day [url=http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html]unless you write your own MySQL function[/url]. ...not that this is a good idea.
[QUOTE=andersonmat;41300550]You may be able to do a LIKE query across the values to match the day and then process the rest of the rows manually by using PHP's split() method to compare the hours. I am not aware of anything that would allow you to analyze each time value as well as the day [url=http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html]unless you write your own MySQL function[/url].[/QUOTE] oh, so get all records which contain specific day and then display out only those that match time? yeah guess that's only option for me in this case.
[QUOTE=arleitiss;41300327]so in my mysql database I am storing days and hours open in one field, called "days", the data is stored in the following format: [Monday:9:17[Tuesday:9:17[Wednesday:10:18[ as you may've guessed, it goes: [Day:From:Till and brackets are just seperators for PHP to distinguish how many days is there. I've been thinking all day what query would be but I could not figure out, so basically I need to get current date and time using PHP: date(l); // Day in full text representation. date(G); // current hour in 24 hour format. So basically I need a query which in simple english would sound like: Select all from businessdetails where column date contains [current date] and :#:# numbers to be less than current hour and greater than current hour. Help? My brain is melting by now.[/QUOTE] Your brain is probably melting because that is a really fucked up way of storing that data. Have an hours table with these columns: [list] [*]business_id [*]monday_open [*]monday_close [*]tuesday_open [*]tuesday_close [*]etc.. [/list] There are better ways you could do it if you need to account for places closing mid day or anything like that, but that will be miles better than what you've got going on now because you can just check the open and close times, get the business id, and use that id to load the business data from the businesses table. Your data should always be organized in a way that makes it incredibly easy to query unless you are NEVER going to query based on that data, and even then the vast majority of the time it's better to have your data very well separated and spelled out like what I've suggested. Generally speaking, if you're putting more than one piece of data in a column you are doing it wrong.
Is it a bad idea to set up phpbb forums on the same webserver as my fastdownload for garry's mod?
[QUOTE=capnsparrow;41306322]Is it a bad idea to set up phpbb forums on the same webserver as my fastdownload for garry's mod?[/QUOTE] It should be fine, if you set it up correctly.
I don't really think I'm going to get into this sort of thing, but does anyone here know a thing about doing some freelance web development? What sort of skills do you need, how would one get started etc etc?
[QUOTE=benbb;41314658]I don't really think I'm going to get into this sort of thing, but does anyone here know a thing about doing some freelance web development? What sort of skills do you need, how would one get started etc etc?[/QUOTE] I'm putting together a site for a small business after having taken just one Udacity class (the one on [URL="https://duckduckgo.com/l/?kh=-1&uddg=https://www.udacity.com/course/cs253"]Web Dev[/URL] was really fun and informative) and reading part of a dated book on PHP. I'm not using any frameworks or anything, but I would highly recommend you do; as a rule of thumb if there is a library/framework to do it, you probably can't do it as well on your own. One example is that in the Udacity class you roll your own password handling functions, but he then drills into your head that you ought to use a library like BCrypt (which the new [URL="http://php.net/manual/en/ref.password.php"]PHP password handling functions[/URL] now use as default). Also, what's a good icon set for a directory listing? I really only need two (one file and one folder) and maybe some sort of arrow to indicate up one directory.
You could use[URL="http://icomoon.io/app/"] IcoMoon's app[/URL] to select only those three (although I would select more just in case I need them in the future).
[QUOTE=Coment;41319777]You could use[URL="http://icomoon.io/app/"] IcoMoon's app[/URL] to select only those three (although I would select more just in case I need them in the future).[/QUOTE] Thanks, these are great! It looks like the page you linked has only free sets, right? I don't want to use anything which I have to license or anything like that.
Sorry, you need to Log In to post a reply to this thread.