Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
SmirkingJack
Nov 27, 2002
Here is a tip that I just had occasion to learn. If you are uploading relatively large files you not only have to make sure that in php.ini not only is upload_max_filesize set high enough but also post_max_size. I could not figure out for the life of me why there was no $_POST variable when I clicked submit until I learned of post_max_size's existence.

Adbot
ADBOT LOVES YOU

SmirkingJack
Nov 27, 2002

Foolio882 posted:

Dear god somebody please help!

php:
<?php
echo "test";
$im createfromjpeg('../images/test.jpg');

if (!$im) 
{
    die ('Unable to open image');
}

echo "Image Opened";
?>
Outputs...

test
Fatal error:Call to undefined function createfromjpeg() at line whatever


GD Version 2.0.34 is installed, with jpeg support.

Anyone have any ideas? Once I get this poo poo worked out I can actually start this project :mad:

imagecreatefromjpeg()?

SmirkingJack
Nov 27, 2002
Here's a time saving tip that can obviously be applied anywhere, but I first started using it with PHP's website. If you use Firefox then navigate over to php.net, right click on the search box and add a keyword of 'php' to the search. Now whenever you need to look up a function hit Ctrl+L (or otherwise get the focus on the address bar), type 'php <<function name>>' and there you are. It also works great if you don't remember the exact name but can come close, which is how I found imagecreatefromjpeg() from createfromjpeg().

SmirkingJack
Nov 27, 2002

Tap posted:

I've recently taken up PHP as my language of choice for learning how to program.

I now have a simple question regarding naming conventions in PHP.

When a variable or function is declared with a single underscore as the first character (i.e. $_foo or $_fake_function()), what exactly does this tell me as a programmer?

It's a kludge of sorts. Until PHP5 there was no way to make a variable or method private, meaning inaccessible to other objects/functions/etc so people would prepend the name with an underscore to tell other people not to use it directly. It won't stop them from doing so, but it suggests the user should do otherwise.

SmirkingJack
Nov 27, 2002
I was digging through some Kohana code and came across this syntax, which I have never seen before:

php:
<?
($field === TRUE) and $field = $this->any_field;?>
What does this do? The context is:

php:
<?
public function add_rules($field, $rules)
{
    // Handle "any field" filters
    ($field === TRUE) and $field = $this->any_field;

    // Get the rules
    $rules = func_get_args();
    $rules = array_slice($rules, 1);

        ...
?>

SmirkingJack
Nov 27, 2002

gibbed posted:

It's the equivilent of:
php:
<?
if ($field === TRUE)
{
    $field = $this->any_field;
}
?>
They're being jerks about the verbosity of their code basically.

Standish posted:

this is called "short-circuiting".
http://en.wikipedia.org/wiki/Short-circuit_evaluation

doing it in the context of
php:
<?
some_func() or die("some_func() returned an error!");
?>
is a very common idiom but using it for assignment like in the example you gave is a bit obfuscated.

Ah, I see. Thanks for teaching me something new!

SmirkingJack
Nov 27, 2002
I have a remote MySQL 5.1 server that I am trying to connect to via SSL. From the command line on the web server (FreeBSD 8, Apache 2.2, PHP 5.2.x), I can use the mysql client and connect just fine by specifying the location of ca-cert.pem, but when I try to connect using mysqli the page just hangs.

'Show processlist' on the remote databases's side shows

pre:
+----+----------------------+--------------------+------+---------+------+-------+------------------+
| Id | User                 | Host               | db   | Command | Time | State | Info             |
+----+----------------------+--------------------+------+---------+------+-------+------------------+
|  2 | unauthenticated user | <web ip>:58711     | NULL | Connect | NULL | login | NULL             |
+----+----------------------+--------------------+------+---------+------+-------+------------------+

Without SSL I can connect via PHP without a problem. This is what I am using:

php:
<?php
    $conn mysqli_init();
    $conn->ssl_set(NULLNULL,"/var/www/certs/ca-cert.pem"NULLNULL); 
    $conn->real_connect($ip$user$pwd$db3306NULLMYSQLI_CLIENT_SSL);
?>

Any ideas, or clues of where to look? I can't find any logs that indicate a problem.

SmirkingJack fucked around with this message at 16:01 on Jan 27, 2010

Adbot
ADBOT LOVES YOU

SmirkingJack
Nov 27, 2002
Does anyone happen to know how to keep PHP errors out of Apache's error log? I set error_log to a separate file, which it is logging to, but the errors are also in Apache's and I'd like to keep them out.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply