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
Zorilla
Mar 23, 2005

GOING APE SPIT

Chinaski posted:

Is there anything within these settings that might be blocking things? The person who configured everything left the company a few while ago and we do not have anyone who can change anything within this configuration right now. Is this something I will have to wait for until we have someone who can do this?

You're setting $email_address, then using $email in the mail() function. Fix this mix-up and it will probably work.

Like usual in this thread, this is where I provide way too much information for beginners...

Provided you're using these fields for email only and not for database inputs, you'll probably want to check to see if Magic Quotes is on, then do stripslashes() on each variable if it is. If you don't, things like quotation marks and other characters with special meanings will end up with backslashes next to them in the message sent out.

This can probably be done with:

php:
<?php
// Magic Quotes is supposedly going away in PHP 6, so I'm checking to see if it's even present here
if ((function_exists("get_magic_quotes_gpc") && (get_magic_quotes_gpc())) {
    $_POST array_map("stripslashes"$_POST);
}
?>

(For MySQL inputs not handled by a fancy library that does security for you, do the exact opposite: check if Magic Quotes is off or nonexistant, then add slashes if that's the case)

For HTML emails, applying htmlspecialchars() to the message body would also be a good idea since you'll need to protect against embedded scripts/hotlinked images/etc.

Zorilla fucked around with this message at 05:32 on Nov 21, 2008

Adbot
ADBOT LOVES YOU

sonic bed head
Dec 18, 2003

this is naturual, baby!

sonic bed head posted:

Thanks but I had already tried that. This is getting extremely frustrating as I'm just trying to write more correct PHP here instead of my old addslashes. I've found nothing that seems like a similar problem to this.

Is there any way I can debug what SQL is actually receiving for the parameters? I've tried mysqli->show_debug_info or whatever but it isn't printing anything.

This whole thing is annoying me to no end. I've been working on it for over a day now and I am no closer to figuring it out. It might be a character encoding problem, but both mysql and mysqli are showing the same character sets.

php:
<?
$db = new mysqli("localhost", "test", "pwd", "serv_test");
$stmt = $db->prepare("INSERT INTO TEST_TABLE(ID,PASSWORD,EMAIL,ATTEMPTS,SUCCESS_DATE,FIRST_TRY_DATE)
 VALUES (?,?,?,1,NOW(),NOW())");
$stmt->bind_param("sss", $a,$b,$c);
$a="aasdasdads";$b="asdasdb";$c="casdasdasd";
$stmt->execute();
$charset = $db->character_set_name();

echo "The current character set is: $charset\n";
?>
This inserts a row in the database with the values: "","ý","",1,1,date,date and prints out "The current character set is: latin1."

php:
<?
$db = new mysqli("localhost", "test", "pwd", "serv_test");
$db = mysql_connect("localhost", "test", "pwd");
mysql_select_db("serv_test", $db);
$charset = mysql_client_encoding($db);
echo "The current character set is: $charset\n";

$a = "aasdasdads";
                $b = "aasdasdads";
                $c = "aasdasdads";
                    $sql = "INSERT INTO TEST_TABLE (ID,PASSWORD,EMAIL,ATTEMPTS,SUCCESS_DATE,FIRST_TRY_DATE) 
VALUES ('$a','$b','$c',1,NOW(),NOW())";
?>
This inserts what is expected and prints out "The current character set is: latin1."

This implies to me that the problem isn't character encoding. Nothing using prepared statements is working for me. What is going on here? Can someone point me in the right direction?

edit:stop breaking tables

sonic bed head fucked around with this message at 03:31 on Nov 20, 2008

me your dad
Jul 25, 2006

Zorilla posted:

You're setting $email_address, then using $email in the mail() function. Fix this mix-up and it will probably work.

I thought I was setting $email_address to whatever is entered into the 'email' field on the HTML form. I think I might have to read up a bit more before I accomplish this goal.

But doesn't that only explain the missing "From" information in the email I receive when testing the form on my personal site? Would that fix the problem I am having at work as well?

Zorilla posted:

Like usual in this thread, this is where I provide way too much information for beginners...

Provided you're using these fields for email only and not for database inputs, you'll probably want to check to see if Magic Quotes is on, then do stripslashes() on each variable if it is. If you don't, things like quotation marks and other characters with special meanings will end up with backslashes next to them in the message sent out.

This can probably be done with:

php:
<?php
// Magic Quotes is supposedly going away in PHP 6, so I'm checking to see if it's even present here
if ((function_exists("get_magic_quotes_gpc") && (get_magic_quotes_gpc())) {
    array_map("stripslashes"$_POST);
}
?>

(For MySQL inputs not handled by a fancy library that does security for you, do the exact opposite: check if Magic Quotes is off or nonexistant, then add slashes if that's the case)

For HTML emails, applying htmlspecialchars() to the message body would also be a good idea since you'll need to protect against embedded scripts/hotlinked images/etc.

Thanks for the extra info. Extra stuff is always good. I'll have to muck about with this today at work to see if I can get it to work.

Zorilla
Mar 23, 2005

GOING APE SPIT

Chinaski posted:

I thought I was setting $email_address to whatever is entered into the 'email' field on the HTML form. I think I might have to read up a bit more before I accomplish this goal.

You were setting $email_address to the value of $_POST["email"], then using $email, which didn't exist. Just do something like this:

php:
<?php
if ( !($_POST["subject"]) || !($_POST["message"]) || !($_POST["email"]) ) {
    header("Location:form.html)"// change this to whatever your form's name is
}

if ( (function_exists("get_magic_quotes_gpc")) && (get_magic_quotes_gpc() ) {
    $_POST["message"] = stripslashes($_POST["message"]);
    // ok, so I didn't really need array_map() for just one variable
}

mail(
    "myemailaddress@gmail.com",
    "Subject: ".$_POST["subject"],
    $_POST["message"],
    "From: ".$_POST["email"]
);
?>
Thank you for using our mail form.<br />
Your email has been sent.
This is all before even talking about PHPMailer, which I recommend because it gives you the opportunity to do all sorts of stuff like SMTP, authentication, SSL, TLS, and file attachments fairly automatically. You can't always rely on sendmail being configured properly, so I'd use it in the future.

Zorilla fucked around with this message at 05:31 on Nov 21, 2008

Pivo
Aug 20, 2004


Hi guys, quick question.

I'm using PEAR MDB2 to access a MySQL database for a client of mine. DB is on same server is Apache, etc typical small business LAMP running on a VPS.

I've got a weird bug: we have one page which loads pretty much every client from the database, and does further queries on each one. This page takes about 10 seconds to load, which is perfectly acceptable given the amount of information generated.

This page also has search options. Here's the problem: if I let the page load fully, then search, the search is done instantly. If I interrupt the page load with a search, then my browser waits absolutely FOREVER for PHP. I think it is waiting for the previous request to time out before fulfilling the next request. Even if it was still fulfilling the previous request, why would it take so long?

I'm not sure where the problem is. As far as I know, Apache should handle the new request like any other, PHP should open up a new db connection and everything should be nice and quick regardless of what it was working on before.

I also fear this means that if two people were to load this page at once, their requests would somehow be processed serially as well.

Is there something I'm missing?

edit: It is waiting exactly 120 seconds, which is the connection timeout. Hmm.

Pivo fucked around with this message at 16:54 on Nov 20, 2008

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

Are you using pconnect? Also the page might be pushing your server loads up. You might want to try tinkering with the my.cnf

Pivo
Aug 20, 2004


drcru posted:

Also the page might be pushing your server loads up.

Nope .. even after sitting there refreshing the page every time it loads, avg short-term load never exceeds 0.05. MySQL never uses more than 3% CPU etc. It's definitely not a crazy page computationally, it's just a lot of tables being joined together.

And no, I am using MDB2::connect(). Again, if I wait the 10 or so seconds for my browser to say 'Done', the next request to the page completes in 10 seconds. If I interrupt the page being loaded to either reload it again or to perform a search, I see a blank page for 120 seconds, which happens to be the timeout value phpinfo() lists for apache2handler.

I know I can set up PHP to either continue running on a connection interrupt, or to abort. Even if it continues running, it shouldn't be waiting for the entire timeout.

Pivo fucked around with this message at 18:19 on Nov 20, 2008

jasonbar
Apr 30, 2005
Apr 29, 2005

Chinaski posted:

I thought I was setting $email_address to whatever is entered into the 'email' field on the HTML form. I think I might have to read up a bit more before I accomplish this goal.

But doesn't that only explain the missing "From" information in the email I receive when testing the form on my personal site? Would that fix the problem I am having at work as well?


Thanks for the extra info. Extra stuff is always good. I'll have to muck about with this today at work to see if I can get it to work.

It shouldn't change the actual delivery of the message. Are you sure the PHP config points to the correct sendmail? Are you sure the PHP user has permission to use sendmail?

Try creating a new script that does nothing but send an email to you - and hardcode all of the data: mail("you@work.com", "test", "blah", "From: You <you@work.com>"); What happens then? Can you check the mail logs? If so just search for your email address and see what it says. Do the apache error logs have anything about mail() failing?

edit: are there other PHP scripts that send mail successfully on the same server? Is the mail service even running on that server?

jasonbar fucked around with this message at 20:48 on Nov 20, 2008

me your dad
Jul 25, 2006

jasonbar posted:

It shouldn't change the actual delivery of the message. Are you sure the PHP config points to the correct sendmail? Are you sure the PHP user has permission to use sendmail?

Try creating a new script that does nothing but send an email to you - and hardcode all of the data: mail("you@work.com", "test", "blah", "From: You <you@work.com>"); What happens then? Can you check the mail logs? If so just search for your email address and see what it says. Do the apache error logs have anything about mail() failing?

edit: are there other PHP scripts that send mail successfully on the same server? Is the mail service even running on that server?

All I know of the configuration is what I posted on the previous page.

I will try the script you suggested tomorrow. I unfortunately don't have access to the mail logs or error logs.

There is a text box on the main intranet site that is intended as a way for users to send comments and such to the person who wrote the site originally. I don't know if it's functioning or not but maybe I can find the script on the server and take a look. That guy is no longer around though and getting info about the configuration and whatnot is going to be impossible until we get a replacement developer.

me your dad fucked around with this message at 00:53 on Nov 21, 2008

Sparta
Aug 14, 2003

the other white meat
Okay, I wrote this big huge script (big compared to what I've done before) and when I try to run it, nothing happens.

http://metrics.cc/doesntwork.txt

There's the php (posted it there so I can delete it after, and because it's biggish).

I have no idea why nothing is working. I put in little 'checks' (updateStatus) but that's not working for some reason. I couldn't find any missing semicolons, and the code I am using is pretty simple. The gathering code (the stuff that pulls from google, alexa, and compete) works, and is currently working in another script.

I can't for the life of me figure out why this isn't working.

What have I messed up?

Edit: the mysql structure explained in the top is wrong, but that doesnt matter, the code is formed right (for inserts).

Sparta fucked around with this message at 05:13 on Nov 21, 2008

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Sparta posted:

Okay, I wrote this big huge script (big compared to what I've done before) and when I try to run it, nothing happens.

http://metrics.cc/doesntwork.txt

There's the php (posted it there so I can delete it after, and because it's biggish).

I have no idea why nothing is working. I put in little 'checks' (updateStatus) but that's not working for some reason. I couldn't find any missing semicolons, and the code I am using is pretty simple. The gathering code (the stuff that pulls from google, alexa, and compete) works, and is currently working in another script.

I can't for the life of me figure out why this isn't working.

What have I messed up?

Edit: the mysql structure explained in the top is wrong, but that doesnt matter, the code is formed right (for inserts).

I'd have to set up a database to run this, it's probably easier to help you troubleshoot on your end.

What gets printed when you run the page? Does updateStatus get run at all?
Does it print everything properly but just not work, or what?

edit: you are actually calling checkEntry/updateEntry somewhere, right?

ante fucked around with this message at 08:40 on Nov 21, 2008

Sparta
Aug 14, 2003

the other white meat
The problem is that nothing runs at all. I am running a test file that reads:

php:
<?php
    include('gather.php');
    checkEntry('metrics.cc');
?>
When I run this it returns nothing:
http://metrics.cc/gathertest1.php

Lankiveil
Feb 23, 2001

Forums Minimalist
What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there.

Murodese
Mar 6, 2007

Think you've got what it takes?
We're looking for fine Men & Women to help Protect the Australian Way of Life.

Become part of the Legend. Defence Jobs.

Lankiveil posted:

What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there.

It very much depends on what you're after. We use CodeIgniter because we sometimes have to deploy on php4 servers, and CI is 4/5. Kohana is a fork of CI by php purists that is php5 only - I don't know much about the differences. Kohana to me seemed to just be a php5 only version of CI with matchbox built in.

Zend/Cake/Symfony I've never used.

gibbed
Apr 10, 2006

Lankiveil posted:

What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there.
I'm quite partial to Agavi.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Lankiveil posted:

What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there.

I'm a CodeIgniter guy, mainly because I started using it because I had a site that was still on PHP4. I really like it, and recommend it. I looked at Kohana ~6-8 months ago, but the documentation was very lacking back then. If they have improved that, and you are on PHP5, I would recommend it as well, as it is faster / more modern.

me your dad
Jul 25, 2006

jasonbar posted:

edit: are there other PHP scripts that send mail successfully on the same server? Is the mail service even running on that server?

As a follow up, I found a simple "suggestion" script on the server:

php:
<?php
            $to "emailaddress@domain.com";
            
            $subject "Suggestion";
                // message
                // To send HTML mail, the Content-type header must be set
            $headers  'MIME-Version: 1.0' "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
            // Additional headers
            $headers .= 'From: Customer Service' "\r\n";
            // Mail it
            mail($to$subject$message$headers);
?>
Suggestion Sent:<br><hr><BR>
<?
    echo "Message: $message";
?>,
(Obviously email addresses have been made generic)

That script is tied to this form:
code:
<html>
	<body>	
		<form name="suggestions" action="suggest.php">
			<textarea name="message"></textarea><br>
			<input type="submit" name="submit" value="Submit">
			<p>(all suggestions are anonymous, include your name if you'd like someone to contact you)</p>		
		</form>
	</body>
</html>
I modified the suggest.php file to include my own email address in the $to field and uploaded it to the directory I have access to, along with the HTML form. Unfortunately no email was generated.

I also tested the suggestion form as I found it on the intranet originally. So if I hear back from anyone I'll know if it's just me who can't send email.

Otherwise, I'll keep digging around and messing with it.

jasonbar
Apr 30, 2005
Apr 29, 2005

Chinaski posted:

As a follow up, I found a simple "suggestion" script on the server:

I bet that either the path to send mail is incorrect, or that the permissions on it are screwy.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Chinaski posted:

As a follow up, I found a simple "suggestion" script on the server:


I modified the suggest.php file to include my own email address in the $to field and uploaded it to the directory I have access to, along with the HTML form. Unfortunately no email was generated.

I also tested the suggestion form as I found it on the intranet originally. So if I hear back from anyone I'll know if it's just me who can't send email.

Otherwise, I'll keep digging around and messing with it.

The script you have there assumes GLOBALS is on... which 99% of the time it isn't. You;ll need to extract the $message from the POST or GET (your form doesn't specify an action, so it whatever your server defaults to)

php:
<?
$message = $_POST['message'];
?>

Sparta
Aug 14, 2003

the other white meat

Sparta posted:

Okay, I wrote this big huge script (big compared to what I've done before) and when I try to run it, nothing happens.

http://metrics.cc/doesntwork.txt

There's the php (posted it there so I can delete it after, and because it's biggish).

I have no idea why nothing is working. I put in little 'checks' (updateStatus) but that's not working for some reason. I couldn't find any missing semicolons, and the code I am using is pretty simple. The gathering code (the stuff that pulls from google, alexa, and compete) works, and is currently working in another script.

I can't for the life of me figure out why this isn't working.

What have I messed up?

Edit: the mysql structure explained in the top is wrong, but that doesnt matter, the code is formed right (for inserts).

Sparta posted:

The problem is that nothing runs at all. I am running a test file that reads:

php:
<?php
    include('gather.php');
    checkEntry('metrics.cc');
?>
When I run this it returns nothing:
http://metrics.cc/gathertest1.php

Can anyone point me to a PHP debugger or something to fix this?

Edit: turned on display_errors and now I can debug it.

Sparta fucked around with this message at 22:52 on Nov 21, 2008

Pivo
Aug 20, 2004


So, no one knows why PHP is waiting for the whole Apache timeout when interrupted? Maybe it's more of an Apache question.

I changed the timeout to 3 seconds, which seems to work well as a hack, but I hope no one tries to browse this page over satellite or a slow cell network.

toby
Dec 4, 2002

Sparta, just so you know I can't get to http://metrics.cc/doesntwork.txt , don't know if it's the same for others.

Sparta
Aug 14, 2003

the other white meat

Pivo posted:

So, no one knows why PHP is waiting for the whole Apache timeout when interrupted? Maybe it's more of an Apache question.

I changed the timeout to 3 seconds, which seems to work well as a hack, but I hope no one tries to browse this page over satellite or a slow cell network.
Turned out it was a . missing from a very long string.

toby posted:

Sparta, just so you know I can't get to http://metrics.cc/doesntwork.txt , don't know if it's the same for others.

That's kind of weird, because it is there, and I can access it, but a friend of mine said he had trouble getting to it too. Something is wonky with my server or something.

However, display_errors let me debug it (along with my actual running scripts, whoops) and now I just need to fix some logic errors.

Actually I might need help here:
php:
<?
function checkEntry($url)
    // checkEntry checks to see if there is an entry for a domain
    // If there is, it returns the latest entry
    // If not, it gathers info and then returns the latest (only) entry
    {
        connectDB('metricsc_metrics');
        updateStatus("Connected.");
        $query = "SELECT * FROM entries WHERE domain='".$url."' ORDER BY timestamp DESC LIMIT 1";
        updateStatus($query);
        $result = FALSE;
        $result = mysql_query($query);
        updateStatus("Queried.");
        updateStatus($result);
        if($result)
        {
            updateStatus("There was an entry.");
            $now = time();
            $then = $result['timestamp'];
            $acceptable = $now - (60 * 60 * 24 * 5); // 5 Days
            updateStatus("Time variables set.");
            if ($then > $acceptable)
            // If the the most recent timestamp is larger than
            // the acceptable minimum
            {
                updateStatus("Timestamp within range, returning result.");
                return $result;
            } 
            else
            {
                updateStatus("Timestamp out of range.");
                $result = updateEntry($url);
                updateStatus("Entry inserted and now returning.");
                return $result;
            }
        } 
        else 
        { 
            // Gather information and return result
            updateStatus("No result, false. Updating.");
            $result = updateEntry($url);
            updateStatus("Entry inserted and now returning.");
            return $result; 
        }
        updateStatus("Closing MySQL.");
        mysql_close();
    }?>
When I run a test, it always says there is an entry (When there is not) and always says the timestamp is out of range (Which shouldnt be true, as the script has run once recently, putting in an entry that is within 5 days).

I'm running my little testing helper, and when I ask for what it's getting from "SELECT * FROM entries WHERE domain='metrics.cc' ORDER BY timestamp DESC LIMIT 1 " is "Resource id #6". What? It's got this every single time, before there was an entry and after.

Sparta fucked around with this message at 23:15 on Nov 21, 2008

toby
Dec 4, 2002

I may be missing something, just looking it over quickly, but try:

php:
<?
        $result = mysql_query($query);
        updateStatus("Queried.");
        updateStatus($result);
        if(mysql_num_rows($result) > 0)
        {
            updateStatus("There was an entry.");
            $then = strtotime($result['timestamp']);
            $acceptable = strtotime("-5 days",strtotime(date()));
            updateStatus("Time variables set.");
            if ($then > $acceptable)
?>
I think $result will come back as non-false even if zero rows are returned, you need to see if you're getting any rows.

As far as the date thing goes, maybe this will fix it.

Sparta
Aug 14, 2003

the other white meat

toby posted:

I may be missing something, just looking it over quickly, but try:

php:
<?
        $result = mysql_query($query);
        updateStatus("Queried.");
        updateStatus($result);
        if(mysql_num_rows($result) > 0)
        {
            updateStatus("There was an entry.");
            $then = strtotime($result['timestamp']);
            $acceptable = strtotime("-5 days",strtotime(date()));
            updateStatus("Time variables set.");
            if ($then > $acceptable)
?>
I think $result will come back as non-false even if zero rows are returned, you need to see if you're getting any rows.

As far as the date thing goes, maybe this will fix it.

First, thank you so, so much for your help. I appreciate this and I know you're probably a busy person.

On to code. The timestamp stored in the db is an int equal to time() when submitted. I didn't discover there was an actual timestamp field in MySQL until after I designed all this. Any way, I used your code and modified it to have proper comparisons, and I'm pretty sure that code is all fine now. The problem seems to be how I'm getting the row from MySQL.

The problem is that $results['timestamp'] doesn't return anything. And when I try to output the array I get from the MySQL row, I get "Resource ID# 61". I tested the code in MySQL, and the query is returning the row fine. Maybe it's in a format different from an array or something?

SELECT * FROM entries WHERE domain='metrics.cc' ORDER BY timestamp DESC LIMIT 1

That's the query I am doing. It works in MySQL. However, no array is returned. Do I have to do something to make an array out of whatever output that's in?

:siren: Edit: :siren:
Figured it out. Had to add in '$result = mysql_fetch_array($result, MYSQL_ASSOC);' so it would be an array. Now I just need to sort out the right logic.

Sparta fucked around with this message at 02:57 on Nov 22, 2008

Sparta
Aug 14, 2003

the other white meat
HELL YES.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Sparta posted:

On to code. The timestamp stored in the db is an int equal to time() when submitted. I didn't discover there was an actual timestamp field in MySQL until after I designed all this.

This is the way I'd do it anyway. The MySQL timestamp field fills it with a string that looks like 2008-09-16 17:31:34, which is pretty retarded imo

jasonbar
Apr 30, 2005
Apr 29, 2005

toby posted:

Sparta, just so you know I can't get to http://metrics.cc/doesntwork.txt , don't know if it's the same for others.

It seems his issue is fixed but along with this, metrics.cc hasn't resolved for me since he originally posted his question. It fails from 3 locations on the west coast, 2 in NY state and from my home in VA. Weird.

geetee
Feb 2, 2004

>;[

ante posted:

This is the way I'd do it anyway. The MySQL timestamp field fills it with a string that looks like 2008-09-16 17:31:34, which is pretty retarded imo

It's worth noting that the DATETIME type supports a wider range of dates ('1000-01-01 00:00:00' to '9999-12-31 23:59:59') -- however, it does take up 8 bytes instead of the integer's 4.

I don't see anything retarded about the format. It's a standard format, they're easy to sort and easy to parse if needed. You can also use helpful built-in functions like DATE_ADD and DATE_SUB. (I'm not sure if you can use them with unix timestamps -- guessing not, but don't take my word for it.)

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

geetee posted:

It's worth noting that the DATETIME type supports a wider range of dates ('1000-01-01 00:00:00' to '9999-12-31 23:59:59') -- however, it does take up 8 bytes instead of the integer's 4.

I don't see anything retarded about the format. It's a standard format, they're easy to sort and easy to parse if needed. You can also use helpful built-in functions like DATE_ADD and DATE_SUB. (I'm not sure if you can use them with unix timestamps -- guessing not, but don't take my word for it.)

Almost every single time I've ever used time in a MySQL database is a timestamp of when the data was entered. I don't want to have to think about it after it's in a table. That means I shouldn't have to worry about parsing MySQL's date format into one that's easier to work with in PHP.

The DATETIME type ensures that I'l' generally have to put more work into displaying the desired format, because I will rarely use the default one. Yeah, it's not much work, but it's work I shouldn't have to do.


MySQL's format does have its uses, but it's the exception, not the rule. I don't often need to use the years 1000-1901 in a database.

Little Brittle
Nov 1, 2004

Come visit me dawg
I've been banging my head against this problem all day. I created an image upload form which puts images in a specified folder, and using the GD2 library, I attempt to resize and create a copy of that image in new folder. GD2 keeps failing because it can't read the uploaded image. I've tested the image resizing script with images I FTP'd, and it works perfectly. It just gets hung up on uploaded files. The image is uploaded with user 'apache' chmod 644, and the directory is chmod 777. Why can't the GD2 library access the uploaded file? Shouldn't it be able to read all images in a 777 permission folder? Is there anything I can do to fix that?

Little Brittle fucked around with this message at 09:47 on Nov 22, 2008

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Little Brittle posted:

I've been banging my head against this problem all day. I created an image upload form which puts images in a specified folder, and using the GD2 library, I attempt to resize and create a copy of that image in new folder. GD2 keeps failing because it can't read the uploaded image. I've tested the image resizing script with images I FTP'd, and it works perfectly. It just gets hung up on uploaded files. The image is uploaded with user 'apache' chmod 644, and the directory is chmod 777. Why can't the GD2 library access the uploaded file? Shouldn't it be able to read all images in a 777 permission folder? Is there anything I can do to fix that?

chmod the file to 777 in the PHP script after you upload it

Little Brittle
Nov 1, 2004

Come visit me dawg

fletcher posted:

chmod the file to 777 in the PHP script after you upload it
I get a 'you do not have permission' error when I run chmod(). I can't even change the permissions via FTP after the file has been uploaded.

er0k
Nov 21, 2002

i like ham.
You really shouldn't chmod things to 777. Better to chown it to whoever owns the httpd.

Pivo
Aug 20, 2004


Sparta posted:

Turned out it was a . missing from a very long string.

Huh? Misquote?

Sparta
Aug 14, 2003

the other white meat

Pivo posted:

Huh? Misquote?

I missed a period when I was stitching together a string.

Sparta
Aug 14, 2003

the other white meat

Sparta posted:

I missed a period when I was stitching together a string.

I think that means I'm pregnant.

Anveo
Mar 23, 2002

Lankiveil posted:

What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there.

No one really talks about it around here, but I think Symfony is one of the best full stack web development frameworks out there.

I researched Zend, Code Igniter, CakePHP and have used Django and Rails, and it really seems to take some of the best features from many of them(it is extensible enough where its trivial to use components of the Zend framework). Symfony has actually converted ideas and some code from Rails, Django, and Spring to PHP - and Django has even incorporated some ideas from symfony. It is also completely modular and any part can be overridden should you need to change or *really* customize something.

It doesn't really reinvent the wheel, and uses proven and mature third party libraries for some things(Prado and I18N, Propel or Doctrine for ORM). Again everything is very modular and can be swapped out for something else.

Symfony is *really* powerful, fully object oriented, and extremely clean for PHP. The only possible downside is certain documentation could be better for some of the newest features.

It does requires PHP >= 5.2 which might prevent some from using it, but it keeps the code clean. I personally think it also requires you to have a moderate understanding of how the web/http works, along with moderate knowledge of OO.

And if it makes any difference, Yahoo uses it for Delicious, Answers, and Bookmarks.

If you are going to look into it, you will probably want to start with version 1.2.

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

Lankiveil posted:

What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there.

I tried them all and keep going back to codeigniter. I do use some Zend libraries within it though. One nice thing about Zend is that it is very modular and well written as far as dependencies go. You can grab modules out of it and just use those pieces without having to do a bunch of framework wide stuff. However, the View and Controller stuff in Zend were really frustrating for me to use.

In codeigniter its pretty easy to replace stuff with your own junk. For instance you don't have to use their model or db objects, its pretty easy to write your own within their framework.

Adbot
ADBOT LOVES YOU

mcw
Jul 28, 2005

Lankiveil posted:

What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there.

I'm probably not the best guy to ask about this because my opinion of my own abilities is pretty low. But the way I make use of frameworks is to use one for a few months on hobbyist projects, taking the best ideas from it and incorporating them into my personal coding standards; then I move on to something else and repeat the process. Meanwhile, for any projects I actually release, I write all the code myself, reusing any useful classes I've written previously. I suspect that this is an ideal that isn't very practical for folks who write PHP professionally.

All that having been said, my personal favorite framework is still CodeIgniter.

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