jazzman1
Staff Alumni-
Posts
2,713 -
Joined
-
Last visited
-
Days Won
12
Everything posted by jazzman1
-
Or....if want to be exactly like your output: products.txt apple orange orange grape lemon lemon lemon mango $file = array_filter(array_map('trim', file('products.txt'))); $products = (array_count_values($file)); foreach ($products as $key=>$value) { echo ($value == 1) ? $key : $key.' '.$value.'x'; echo '<br />'; } Results:
-
Try, <?php $file = array_filter(array_map('trim', file('products.txt'))); $products = (array_count_values($file)); foreach ($products as $key=>$value) { echo $key.'('.$value.')'."<br />"; } Results: P.S products.txt is the file that contains strings of products.
-
The right syntax should be something like: SELECT * FROM tbl_name WHERE column_name_1 LIKE '%a%' AND column_name_2 LIKE '%b'; Also, don't quote the tables and columns it's a wrong sql syntax. Sorry, I am in a hurry.
-
And the columns?
-
Google "how to html and php" or something similar. Every "<?" tags in your scripts must be "<?php".
-
Is there a table named - WHERE 'Short Item Name' ? If does, why did you quote it?
-
Aside, don't mess up the full and short php opening tags.
-
That depends of your hosting provider, just check the helping guide manual that they provide to their customers.
-
The easiest way is to create a custom php.ini file which overridding the main php.ini file from the server, or to use ini_set setting new values. EDIT: The other way is to hack the server
-
Did you restart apache?
-
Wow....dude...a lot of code, use the code (<>) tags that the editor of the forum provides us Just put down error_reporting(-1) on the top of your files and for debugging sql's use mysql_error()
-
Check this thread, especially my last post it would help you I guess.
-
If you're planning to install Linux as second OS you might consider checking the hardware compability list in linux.
-
Never ever run queries in loop, It’s so easy to start hammering the database with a crazy number of queries. So, turn on your error_reporting and also check out that thread - http://forums.phpfreaks.com/topic/267013-looping-multiple-rows-into-database/
-
Well, requinix's solution should not work according that log (/var/www/html/dd/subdir), it should be work only if you moved the menu.php file outside of the project. In RedHat /CentOS /Fedora the web root directory is named html, so in that case "dd" is your project folder not a web root as you posted in your first post.
-
So, here is the test using my local CentOS machine. Check the status of sendmail client to be sure that we don't use it: [jazz@centos-box ~]$ su -c '/etc/init.d/sendmail status' Password: sendmail is stopped sm-client is stopped Now I will try to use my google account sending a message(s) to my yahoo mail account. <?php // include the library require_once 'Swift-5.0.0/lib/swift_required.php'; date_default_timezone_set('America/Toronto'); // Create the Transport $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl') ->setUsername('accountName@gmail.com') ->setPassword('myPassword') ; // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); $subject = 'Wonderful Subject From SwiftMailer'; $body = '<p>Here is the message itself</p>'; // that's your html content $message = Swift_Message::newInstance() ->setContentType("text/html") ->setMaxLineLength(100) ->setSubject($subject) ->setFrom(array("centos-box@localdomain" => "jazzman")) ->setTo(array('myEmail@yahoo.com' => 'jazzman')) ->setBody($body); // Send the message $numSent = $mailer->send($message); printf("Sent %d messages\n", $numSent); Result: So, to use this method you don't have to have a mail server on the machine just we're using a remote mail server over ssl.
-
Ops....I just forgot to add setTo() or if you prefer setBcc() methods. So the message should be something like: $message = Swift_Message::newInstance() ->setContentType("text/html") ->setMaxLineLength(100) ->setSubject($subject) ->setFrom(array("centos-box@localdomain" => "jazzman")) ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) ->setBody($body); That's all.
-
I don't have a previous attempt with phpMailer, so I will give you an example in swiftMailer. It's a pretty simple: <?php // include the library require_once 'lib/swift_required.php'; // Create the Transport $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465) ->setUsername('your username') ->setPassword('your password') ; // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); $subject = 'Wonderful Subject From SwiftMailer'; $body = '<p>Here is the message itself</p>'; // that's your html content $message = Swift_Message::newInstance() ->setContentType("text/html") ->setMaxLineLength(100) ->setSubject("' . $subject . '") ->setFrom(array("centos-box@localdomain" => "jazzman")) ->setBody($body); // Send the message $numSent = $mailer->send($message); printf("Sent %d messages\n", $numSent);
-
The easiest way to achieve that is to use some php mail library as swiftmailer, phpMailer.... I'm a swiftmailer fan or you want to create everything from scratch? http://swiftmailer.org/docs/sending.html
-
doesn't send email with gmail smtp through fsockopen()
jazzman1 replied to RieqyNS13's topic in PHP Coding Help
He-he, I was completely forgot about that I'm using openssl on my RedHat server but in Bash language. Good job -
doesn't send email with gmail smtp through fsockopen()
jazzman1 replied to RieqyNS13's topic in PHP Coding Help
Turn on error_reporting and try something like that: $fp = fsockopen("ssl://smtp.gmail.com", 465, $errNo, $errStr, 15); $str = "EHLO \r\n AUTH LOGIN \r\n "; $str .= base64_encode("author@gmail.com")."\r\n"; $str .= base64_encode("password")."\r\n"; $str .= "etc......"; fputs($fp,$str); fclose($fp); Are you sure that your email header format is correct, too? -
doesn't send email with gmail smtp through fsockopen()
jazzman1 replied to RieqyNS13's topic in PHP Coding Help
You have to concatenate your string, something like: <?php $fp = fsockopen("ssl://smtp.gmail.com", 465, $errNo, $errStr, 15); $str = fputs($fp, "EHLO"."\r\n"); $str .= fputs($fp, "AUTH LOGIN"."\r\n"); $str .= fputs($fp, base64_encode("author@gmail.com")."\r\n"); $str .= etc...... echo fputs($fp,$str); fclose($fp); Or.....much better, create the string and pass it as a second parameter to fputs() -
None of the answers above are corect b/s of lack of server side knowledge. So, the copy php function is a simple and it's works only if the file already exist on the machine (server). When you try to upload a file from a local machine to the server the file is saved as a tmp, that's why mac_gyver proposal is correct to use move_uploaded_file ().
-
Double check kicken's reply. Reserved words require special treatment for use.