logs archiveIRC Archive / Freenode / #php / 2015 / July / 21 / 1
caffinated
notices and warnings are non-fatal errors
__adrian
all errors?
no_gravity
"failed to open stream: No such file or directory" is not a fatal error?
__adrian
it's a warning iirc
(it says, in the error message: first word)
caffinated
it's a warning, because you could potentially recover from that.
no_gravity
ok. will add my own error handler then.
SilentCoder
im sorry guys, http://hastebin.com/wixaloxuhe.coffee i couldnt figure out what was ment by <laszlof> SilentCoder: [':foo'=>$foo, ':bar'=>$bar]
i kept getting an error about array.
caffinated
SilentCoder: $test isn't defined
SilentCoder
i thought that array would populate its self?
         

caffinated
further, if you're binding values already, why would you pass an array to execute() ?
SilentCoder
i tried without the array
just $sql->exectute();
ill give that error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at
caffinated
well, something doesn't add up then. You get that error when the number of placeholders you have in your SQL statement (in prepare) doesn't match the number of things you've bound to it.
SilentCoder
i have two placeholders inside the prepare statement :first and :last
then two for bind
caffinated
first and last are reserved words in mysql
enclose them in backticks (`)
SilentCoder
k
caffinated
$sql =$db->prepare("SELECT * FROM $TBL WHERE (`first` = :first AND `last` = :last");
SilentCoder
okay now its just line 77 Syntax error or access violation: 1064 You have an error in your SQL syntax
or the execute line
$sql->execute();
caffinated
what is the entire error
SilentCoder
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1' in /home/numbappl/public_html/Database.php:77 Stack trace: #0 /home/numbappl/public_html/Database.php(77): PDOStatement->execute() #1 {main} thrown in /home/numbappl/publ
ic_html/Database.php on line 77
caffinated
usually it will as something like "near <some sql here>"
SilentCoder
:)
oh i think i know
"$first' would this solve it
dant
'$first'
because its a string?
caffinated
you're doing something you're not showing me.
assuming the table schema is right, and $TBL contains the appropriate value, it should work fine.
SilentCoder
in the url im $_GET([first]); same with last
with ''
that equals the $first and the $last
caffinated
$_GET([first]); isn't really valid syntax in any situation
SilentCoder
sorry
$first = $_GET['first'];
same with the last
caffinated
that's fine. it doesn't change that there's something else going on with that code
SilentCoder
the the rest of the code is as follows the table contains first and last
then the code looks like this
http://hastebin.com/bonoqivoho.coffee
caffinated
where is $TBL defined?
SilentCoder
its defined at the top
$TBL = "mytable";
i know the table is correct because i can delete entries
         

caffinated
oh, i see why
you've got an open paren with no close
duh
i almost didn't see that
SilentCoder
ill check
caffinated
just eliminate the parens around your WHERE clause
they're not really needed there
SilentCoder
okay
caffinated
$sql =$db->prepare("SELECT * FROM $TBL WHERE `first` = :first AND `last` = :last");
SilentCoder
awe good catch
i missed that too
yep thank you :)
caffinated
no wonder it was reporting ''
it hits the end of the query, errors, and there's nothing to be "near"
SilentCoder
smallest mistakes lead to bigger ones later :)
thank you i would have been stuck forever on that.
well already was haha 2 hours now
scwizard
"Example #3 Sending mail with an additional command line parameter."
command line paramaters to WHAT program???
this is from: http://php.net/manual/en/function.mail.php
caffinated
sendmail
or a sendmail wrapper
scwizard
caffinated: oh ok
laszlof
you probably shouldnt be using mail() anyways
scwizard
i know u_u
caffinated
it's generally safer not to use mail() directly - that's true. Unless you're intimately familiar with how mail transports work
too many ways to screw the pooch with it
Utils
laszlof: done the profiling. done some comparisons, to my surprise, the queries are actually faster in eloquent. I guess it's the processing involved with eloquent that makes the page slow that .02 seconds longer. that in itself isn't a big thing to worry about
the results may very well be different if i had many many more records but... as it stands, its ok.
and I guess with the upcoming release of PHP 7 which is said to be "up to 2 times faster", that would drop those load times.
caffinated
I'd take "up to X times faster" with a half cup of bacon flavored salt
speed gains should always be measured on a per-operation basis
(also, bacon salt is kinda really awesome)
SilentCoder
caffinated, is that injection safe the way im binding?
$sql->bindValue(':first', $first);
because the $first is a user input value. I was just curious or should i do PDO::PARAM_STR
caffinated
SilentCoder: I'd probably set character sets, but past that prepared statements take most of the danger away.
I'd also suggest validation of some kind, depending on what the input gets used for.
SilentCoder
ill read up on validation now thank you caffinated
caffinated
it may not strictly be necessary if those are for first and last names.
(I can't really tell for sure what they're for)
SilentCoder
its to check if the tbl already conatains the name if not i will be adding it later.
caffinated
be sure to do security from both sides
SilentCoder
but the input value comes from my game engine and its strictly string format
caffinated
validate going in to the database, and any time you want to display the data, entify on the way out
SilentCoder
reading now entify and validate
caffinated
htmlentities() are just a way of encoding characters so they're not treated as literal by a browser.
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 next »