« first day (708 days earlier)      last day (4240 days later) » 
00:00 - 21:0021:00 - 00:00

@DaveRandom Wrong. Point 1 can't be circumvented. PDO will always fall back to emulation if you try to prepare an unpreparable query (such as an ALTER)...
 
@ircmaxell Well that sort of sucks. My feeling is that it should throw an error. Although frankly if you're passing user input to DDL queries you deserve everything that comes to you.
 
user1125394
what is really doing FILTER_SANITIZE_EMAIL except from trimming spaces
 
9:17 PM
It removes all illegal characters from emails (not just whitespace). I don't like it, I think it doesn't solve anything. Just FILTER_VALIDATE_EMAIL and if it fails bork. Don't "sanitize" input, corrupting the original data and storing something meaningless.
 
user1125394
yes that's waht I do, thx
 
Hello all
problems with mysqli here
apparently that query is designed for associative fetch
but what on earth does store_results() do?!?!
^ store_result(); where can I go from there?
 
@WilliamYang Why don't you use PDO?
 
@WilliamYang Use PDO. It will save you sooo many headaches in the long run.
 
0
A: File manupulation search an replace csv php

hakraYou need to open the original file and go through each line. When you find the line to be changed, change that line. As you can not edit the file while you do that, you write a temporary file while doing this, so you copy over line-by-line and in case the line needs a change, you change that lin...

 
9:26 PM
procedural?
@ShaquinTrifonoff procedural? :P
why can't they just stick with OO lool
 
@WilliamYang Why not object-oriented?
 
making two ways of doing the same things = headaches
I am trying to do OO :P
 
PDO actually covers several database engines, not just MySQL, so in a way, it's not doing the same thing, it's improving upon what is already there.
 
@WilliamYang Well PDO is what you want then. It is only OO, and much more sensible OO design at that.
 
as someone who is mostly uninterested in this discussion .. emm ... the user seems to be insisting that the is using OOP , while linking all the time to php manual
 
9:30 PM
PDO = too complicated for me atm @.@
I have been using mysqli for less than a week...
 
define "using"
 
in the past all I do is throw around random escaped queries and mysql_execute
 
William, you can learn PDO in less than an hour.
 
PDO is much less complicated.
 
show us some code , or drop the subject
 
9:31 PM
if($prep_stmt = $mysqli->prepare("SELECT password, password_salt FROM accounts WHERE username=?")){
$prep_stmt->bind_param("s", $reg_user); $prep_stmt->execute();

$prep_stmt->store_result();

$query_rows = $prep_stmt->num_rows;

if($query_rows == 1){

}

$prep_stmt->close();
 
@DaveRandom , @David the API choice is secondary
 
I want to keep this simple... and stupid :P
so I am assuming I do the fetch assoc array after store_result()..
except ^ that doesn't do fetch assoc after checking the number of rows
:3
 
<?php
try {
	$db = new PDO('mysql:host=127.0.0.1;dbname=db_here', 'username', 'password');
	$query = $db->prepare('SELECT password, password_salt FROM accounts WHERE username = ?');
	if(!$query) throw new Exception('Failed to prepare query!');
	$query->execute(array($reg_user));
	$result = $query->fetchAll();
	if(count($result) > 0) {
		// ...
	}
} catch(Exception $e) {
	echo 'An error occurred: ' . $e->getMessage();
}
?>
@WilliamYang
 
ohhh -.-
@ShaquinTrifonoff yeah thanks I'll try that in a minute
found out some dude made a post in the manual down the page :P
 
never trust php manual comments
 
9:36 PM
@Lusitanian I wouldn't say never
 
user1125394
Is it possible to check dynamically if a file has already been included, please
 
@Nile when can you trust them?
 
LOOL <?php
class mysqli_Extended extends mysqli
{
protected $selfReference;

public function __construct($dbHost, $dbUsername, $dbPassword, $dbDatabase)
{
parent::__construct($dbHost, $dbUsername, $dbPassword, $dbDatabase);

}

public function prepare($query)
{
$stmt = new stmt_Extended($this, $query);

return $stmt;
}
}

class stmt_Extended extends mysqli_stmt
{
protected $varsBound = false;
protected $results;

public function __construct($link, $query)
{
parent::__construct($link, $query);
}
sorry but this is so much derp :D
 
user1125394
it'a a html header file so pure html
 
@Lusitanian I don't know, some of them aren't useless...
 
9:38 PM
@Nile I said never trust, not never make use of.
 
@Lusitanian okay then
 
@WilliamYang You don't need that..
 
LOOL
@ShaquinTrifonoff I'll try whatever it takes to make it work ^^ including your block
This is soo much derp
xD I think I'll stick with PDO
 
user1125394
E_PARSE: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM < what is that
 
9:43 PM
there is the old mysql_query way, then comes mysqli prepared statements in both procedural and OO fashion, then PDO..
 
@tereško Sorry? I missed that point
@cyril T_PAAMAYIM_NEKUDOTAYIM is ::
 
@cyril syntax error? extra ')'
?
 
It's hebrew, it means "two dots twice"
 
user1125394
I have this:
<?php
if(!isset(tab_bar_main)){
include("header.php");
}
?>
 
9:44 PM
(as in className::staticMember)
 
user1125394
oh I may see
 
@DaveRandom , when you have a user that users MySQLi , the main goal is to make sure that he/she understands how to use prepared statements .. both APIs are actually extremely similar at the surface level
 
@cyril Your missing a $
 
user1125394
@DaveRandom tab_bar_main is a funtion
 
user1125394
I need to check if it's defined or not to know if my html header is loaded
 
9:46 PM
@cyril Right well you want if (!function_exists('function_name'))
 
@cyril if(!function_exists('tab_bar_main')) {
 
(note that you test it as a string value as well)
 
user1125394
I would like to do if (defined? "header?php")
 
user1125394
@ShaquinTrifonoff thx
 
9:47 PM
<?php
if(!function_exists('tab_bar_main')) {
    include_once 'header.php';
}
?>
 
@ShaquinTrifonoff does $query->execute(array($reg_user)); all that the array means is it will store matching rows in separate arrays, right? :P
 
@ShaquinTrifonoff or you could, yknow, include_once 'header.php'; ;)
 
@tereško OK fair point, but since this particular user arrived complaining about the inability to fetch_assoc() from a statement, the difference between PDO and MySQLi is worthy of note, I feel.
 
@cyril include is a language construct, you should not put parentheses around it.
 
@Lusitanian Curse you with your logic and your brain power. We don't like your types around here...
 
9:48 PM
@ShaquinTrifonoff so that's sort of like num_rows, except it's derpier... right? :3
 
user1125394
@ShaquinTrifonoff ok actually tab_bar_main is a function in header.php, but I want to make sure header.php is loaded, (because of several redirects)
 
@WilliamYang execute() takes an array as it's parameter, so the SQL SELECT * FROM foo WHERE bar = ? AND test = ? would end up with the code $query->execute(array(1, 'blah'));.
Aaagh, this is what happens when I'm typing a message:
 
I am almost tehre
but what exactly does (array($reg_user)); do? @ShaquinTrifonoff
 
@cyril Do what @Lusitanian said, just put include_once 'header.php'; in your code.
 
why do I need an array as an execute param? :P
 
9:58 PM
@WilliamYang Each item in the array corresponds to each ? in the query.
 
ehh kill me now > php.net/manual/en/pdostatement.execute.php @ShaquinTrifonoff
 
user1125394
@ShaquinTrifonoff thx
 
note that if you have to check whether or not a file is included, you're probably doing something wrong architecturally
 
ohh nvm
let me read it over before I die
Am I not fetching results correctly in PDO?
 
@WilliamYang Are you using something like $data = $query->fetchAll();?
 
10:06 PM
try {

$dsn = 'mysql:dbname=naginata;host=127.0.0.1';
$user = 'root';
$password = 'anita';

try {
$db = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}

$log_user = 'john';
$query = $db->prepare('SELECT password, password_salt FROM accounts WHERE username :log_user');
//if(!$query) throw new Exception('Failed to prepare query!');
$query->execute(array(':log_user' => $log_user));

$result = $query->fetchAll();

if(count($result) == 1) {
$result[0][0] or $result[0] gives nothing :/ The query is correct
 
@WilliamYang SELECT password, password_salt FROM accounts WHERE username = :log_user. You missed an equals sign.
 
SPOT ON +1 Thanks xD @ShaquinTrifonoff
it works like a charm now :3
 
10:19 PM
the sad state of development
0
Q: How to work with calculations in rails

yor mazarI have a view with a table of products, where each product has values for cost and price. I want to calculate and display the sales margin for each product and above the table put an average margin for all products. Where do I put the calculations? And how do you handle calculations that are cro...

this is like the mock-post with "how to add two numbers in jquery" , but only difference is that this one is serious
 
nobody wants to think for themselves any more, always ask somebody else
that explains the majority of questions on SO
 
@tereško console.log($(2).plus(2)); // 5
 
10:35 PM
@DaveRandom Why is the result 5? :P
 
@ShaquinTrifonoff because jquery made it better
> The Write Less, Do Moar
 
Guys, I have a question. There probably is some naming convention, that is explaining why are variables named as they are. So here is my question, is there some defined conventation, that says, that variables containing object and not being property of the class, should start with capital letter?
 
not that i am aware of
 
thereIsCamelCase, ProperCase, and_i_cant_remember_what_this_is_called
 
@Eugene Not sure whether there is an "official" conventions, but I have seen it in the past
And I hate it :)
 
10:43 PM
@Eugene I don't know of any standard, take your pick and keep your code consistent :-)
 
also, don't forget the the Used_For_Unit_Tests_Case
 
@PeeHaa Why?
@tereško Sure.
It just happened to be my style of writing code and I think it is very readable due to that. Since when you look through you immediately know, that for example this is object and this is simple type.
 
@Eugene Because you shouldn't need some specific conventions for variables which are instances of some class
 
anyway , capitalizing the variables which contain resources not owned by the class (like injected objects) would be just another variation of hungarian notation
 
^that
 
10:47 PM
and you should not care about where the object comes from
 
@tereško You are talking about class properties, right?
 
of course
i assumed we were discussing it in contexts of OOP not procedural code
 
Hi @PeeHaa :)
And Gn8 @all :)
 
@hakra hiya :)
 
@tereško Yes, we are. Just checking :)
 
10:50 PM
Classname should start with a capital letter, however variable names lowercase. (That is one rule that comes to mind, however, not binding, just by convention)
 
So for example writing $Foo = new Foo(); is okay and property in class $this->foo = new Foo();
 
looks not good to me.
 
What about $foo = new Foo(); and $foo = Foo::getPdo();
 
$foo = new Foo();
 
@hakra Why?
 
10:52 PM
@Eugene , in that case i would say , you are doing it wrong .. you should not be using static methods
 
The later part: $foo = Foo::getPdo(); should be wrapped into something else, like $foo = $db->getPdo();
 
@tereško It was just a quick example of geting class from method.
 
@Eugene Its your code, decide what style you want to use and stick to it.
 
@vascowhite That's great until you have to collaborate with other people and you have to switch CS
2
 
10:53 PM
@PeeHaa exact reason of my current discrussion here. :)
 
@Eugene variable names camelcase
classes pascalcase
 
@PeeHaa Then that would make @Eugene'S question redundant
 
funtions camelcase
@vascowhite No the point is to prevent such things ±'
while you can
 
@PeeHaa Ewww...
 
@DaveRandom ?
 
10:55 PM
Functions camelcase? /me says no...
 
@Eugene personal preference?
 
@DaveRandom I think he was talking about methods.
 
I meant lower camelcase or whatever it is called
 
I mean: what is the team CS? Stick to that. if there's no team decide for yourself
 
whatIsThisCalled?
 
10:56 PM
That's camelcase. Did you mean methods or functions?
 
@hakra personal preference: $Foo = new Foo();, $this->foo = new Foo();, $this->foo = $this->getMeAFooForGodSake(); :)
 
methods
8 mins ago, by tereško
i assumed we were discussing it in contexts of OOP not procedural code
 
Oh right that's alright then. Although to be fair with methods it's irrelevant since they are case-insensitive anyway.
@PeeHaa Yeh sorry missed that
 
np :)
 
@Eugene My personal preference is to never start a variable name with a capital and that's what I do, but I don't work in a team.
 
10:58 PM
I_MIGHT_SPEND_NEXT_WEEK_WRITING_CODE_THAT_SHOUTS_AT_YOU
 
this keyboard is driving me mad, it does some strange automatic doubling up of quotes.
Dell
 
$GaRipPleGarApPlE = THISIS::$NOT_A_DEFINE;
 
@Eugene Although I totally dislike the way the FIG works most of the PSR's stuff are common: github.com/php-fig/fig-standards
 
@vascowhite Stop pressing the double quote key :-P
 
You guys seen this: stuck.include-once.org?
 
11:00 PM
@DaveRandom I wish it was that easy. It's a temp until my new one arrives and I hate it.
for example if I type ' followed by i i get í WTF!
 
@vascowhite I actually like my crappy Dell stock kbd at work. Although the Windows key doesn't work on it which is very annoying.
 
@vascowhite ctrl+shift will solve that
 
@PeeHaa Thanks you've just save my kb's life! How did you know?
 
I was just looking for some proof link on that naming matter, since I heard, that this is actualy held as best practice.
 
@DaveRandom I do like the clicky keys
 
11:04 PM
@vascowhite Have had two keyboard layouts in the past. Have been bugged by it a lot :)
@Eugene Have you read the fig link?
 
@PeeHaa It's not a terribly great design clone, but the content is good.
 
user1125394
$f=new Foo;
 
@PeeHaa sorry. Opened it and then lost it. :) Reading right now.
 
@Eugene PHP has "borrowed" (stolen) a lot of it's OO design and conventions from Java. Take a look here and I suspect you'll find a lot that you recognise...
 
I'm looking for a reason to close this stackoverflow.com/questions/12556650/…
 
11:07 PM
@vascowhite Dupe for sure
And maybe too localized (rtfm)
 
@DaveRandom while the basic OO design comes from java , php has been accumulating features from other languages too
 
rtfm would work for me
 
Hey, if people would start to read the manual, how could one repwhore that well?
 
I hadn't thought of it that way, but stupid questions do annoy me.
 
11:13 PM
welcome to club ... line forms on the right side
 
Yes, they can be irritating, because sometimes you read a question and think it's stupid but it ain't.
Anyway me is off to bed now.
 
@tereško Oh I know, it's in no way a carbon copy. Which in some ways is a shame, I often think that PHP's type promiscuity is not such a great thing. I want a proper ENUM as well.
 
@tereško I get the impression you get irritated easier than I do :)
 
are you saying that i was wrong ? .. then again you might be right .. the whole My Very Code movement is somewhat like a raw nerve for me
 
@hakra later
 
11:18 PM
@tereško No, not at all, but I probably would have left out "but you ain't.", although I would have thought it.
 
this user has been trolling stream this weekend
it's kinda annoying
 
What kind of a tosser uses that sort of image as an avatar?
 
the common , garden variety 14-year old .. then again , i might be wrong, because i would have never used anything like that for avatar
 
@DaveRandom maybe that's her :)
 
@vascowhite True, I may be being overly judgemental. Maybe she is using SO hanging upside down on a pole. I'd imagine it would get pretty cold pretty quickly though.
 
11:24 PM
well that's the last glass in that bottle of wine gone. The original plan was to have one glass :)
 
heh .. at that age i used this thing for avatar
 
She's using her ipad
 
actually .. i still might ( since one might see the monogram in it )
 
wtf is that? looks a bit scary, but cool
I prefer my land rover :)
 
@vascowhite , an old avatar of mine
 
11:27 PM
I used a cut down version of this for ages
 
no, I mean what is it a picture of, can't work it out
 
Then I grew up.
 
@DaveRandom cooool man, coool
 
@vascowhite , hard to say , but i would guess it is a dreamcatcher made from bones
 
@tereško ah, ok, It looks a bit like a bat if you squint.
 
11:29 PM
It's got a bit of a scythe-y motif for a dream catcher.
 
Can anyone figure out how I did this? imgur.com/hxBEJ It should be quite easy :-)
 
I like it, I think the grey scale appeals to me
I reckon you should use it for SO @tereško
 
i had the 200x200 version somewhere , but it's on the burned out laptop
i would take some effort to recover it
then again , that same laptop contains contains some interesting and old source code
.. like code for the website of largest local mobile telecommunication company
 
@tereško Is that the laptop you were complaining about being slow last night, or another one?
 
nope .. an older thing
 
11:33 PM
@ShaquinTrifonoff Can you expand on that? I mean it's pretty easy to JS inject to make Google look like that...
 
by the time it died , it had no working cd-rom, the keyboard went tits-up afther 4th time i spilled beer in it and the battery had corked when fusebox in dorms blew , and i had manually cut the beeper
 
@DaveRandom I did it without JavaScript or modification (i.e. Firebug).
 
one day it just stopped working
i suspect it was out of spite
 
@tereško judging by the way you treated it, it was probably justified :)
 
This is a problem with htaccess. I don't know if anyone will be able to help but I will ask it anyway.

I have these two lines in htaccess:
RewriteRule ^register1.php website/register.php
RewriteRule ^rules.php website/rules.php

the problem is, when i put /rules.php, it automatically goes back to register1.php instead of showing rules.php page

I think RewriteRule ^register1.php website/register.php is giving the problem, but don't know how to fix it.

Anyone?
 
11:38 PM
@tereško I had a laptop like that, and literally the day before my replacement arrived (already ordered) someone potted the window on my car and stole it. I was really quite satisfied knowing that some little chav managed to steal the most useless laptop in the world, it cost me nothing to repair the car (was a company car), I already had a replacement ordered, I had already backed up the contents, and I got an insurance claim on it. Winner.
 
Anyone?
 
@DaveRandom , on related note , it's similar how i got my latest phone. It died after i drowned it in some beer. So , i dried it , and went to shop to fix it. Week later they call "we could not fix it, but would you agree to exchange it for newer model from same company for free?"
 
no one?
 
@tereško Really? They usually basically point and laugh at you for liquid damage. I know more than one person who have killed phones by dropping them in pub toilets while drunk :S
 
well .. it was a full-price Sony-Ericsson .. they might have different policy
 
11:43 PM
@DaveRandom Man U, Man C or don't care?
 
@vascowhite Honestly, I have searched high and low, I cannot find less of a sh*t to give. I will check again though.
4
 
lol
good answer
 
wow, no one?
 
@user1079641 apparently not
 
11:45 PM
@user1079641 I don't know much about Apache rewriting, but you might have to put in a RewriteCond for multiple rules.
 
@user1079641 I've just finished a bottle of wine, so I can't be arsed :)
@DaveRandom I'm going to save that phrase for future use :)
 
RewriteCond %{REQUEST_URI} ^rules.php
RewriteRule ^rules.php website/rules.php
@user1079641 Something like that --^
 
I am going to defy convention now and go to bed at something resembling a reasonable hour. Night all
 
No, its not working.
Apparently it shows website.com/rules.php in the url box but the page still shows website.com/register1.php
 
@DaveRandom don't forget to $.brushyourteeth()
 
11:53 PM
@DaveRandom night
 
I'm off too gn all
 
Anyone know how to get PHP DOM to output XHTML-style tags? saveHTML() works great, apart from that. For example, it outputs <meta charset="UTF-8">. I want it to output <meta charset="UTF-8" />. saveXML() does that, but the result is all on one line.
 
I really hope someone else i able to help :(
 
@ShaquinTrifonoff I take it you've tried this php.net/manual/en/domdocument.savexml.php
 
@vascowhite You must not have read the end of my message. I have.
 
11:56 PM
@ShaquinTrifonoff $dom->formatOutput = true;???
 
I did but it didn't register until I posted my answer :) @ShaquinTrifonoff
 
@user1079641 Have you posted a question?
 
No
I thought people on chat will be able to solve it since its a 5 minute issue.
 
@ShaquinTrifonoff php.net/manual/en/…
 
@PeeHaa Yes, I tried that, but the formatting isn't great with that either:
<!DOCTYPE html><html lang="en-NZ">
  <head>
    <meta charset="UTF-8"/>
    <title></title>
    <link rel="stylesheet" type="text/css" href="/css/main.css" media="all"/>
  </head>
  <body>
<p>test</p>

<pre>
test
	test
		test
	</pre></body>
</html>
 
11:58 PM
strange
 
@PeeHaa The </pre> tag is indented like that on purpose, just for testing.
It's a bit better if I use this:
echo $dom->saveXML($dom->doctype);
echo PHP_EOL;
echo $dom->saveXML($dom->documentElement);
 
00:00 - 21:0021:00 - 00:00

« first day (708 days earlier)      last day (4240 days later) »