Click here to Skip to main content

Linux, Apache, MySQL, PHP

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: learn phpmvpRichard MacCutchan19 Sep '12 - 3:53 
Stephan A. wrote:
Rather as I said I wanted to be directed to a good book on this subject
And how do you define "good"? You can ask this question of a lots of people and get lots of answers, many of which will be wrong for you because they are either too basic or too advanced. You really need to do your own initial research when trying to learn a new subject, rather than expecting others to do it for you.
One of these days I'm going to think of a really clever signature.

GeneralRe: learn php [modified]memberStephan A.19 Sep '12 - 6:59 
ok. let's skip it it is not worth it anymore, I am not going to continue it anymore.
 
I'm not sure what you meant with that "words fail me", in any case, I had asked a simple question and wanted a simple answer. Maybe I had to better formulate that I was actually looking for a good book (of course there exists notion of good book, i.e., one that is popular and well received in the community - I think I didn't say anything new here). What I meant more particularly with good book, could be a book that is: easily comprehensible, covers sufficiently many details etc. anyway.....
 
Quote:
And how do you define "good"?

easily
best regards.


modified 19 Sep '12 - 13:16.

GeneralRe: learn phpmvpRichard MacCutchan19 Sep '12 - 8:22 
Stephan A. wrote:
I'm not sure what you meant with that "words fail me",
I mean, why have you been making all this fuss when you had no intention of learning PHP in the first place?
One of these days I'm going to think of a really clever signature.

GeneralRe: learn phpmembercrayben12 Nov '12 - 22:44 
if u have wrote other computer language, u may know how to do with it, the only way to study program is write more and more coder
AnswerRe: learn phpmemberMohibur Rashid18 Sep '12 - 15:08 
I was the dumbest student in my school and university. Yet I learned PHP in 2 hours exact (it was a story to tell). But I mastered in PHP in one years(after I joined a company).
 
Now you are looking for an expert advised and you started with mocking one of the most experts here.
 
The fact is if you don't know how to help yourself and try to understand experts opinion then you would never learn.
 
And final thing is getting a graduation certificate make you a graduate but not educated.
I wish I could believe there is an after life.

AnswerRe: learn phpmemberWamuti27 Sep '12 - 5:11 
Check out this list:
 
https://www.google.co.uk/search?q=learn+php&aq=0&oq=learn+php&sugexp=chrome,mod=8&sourceid=chrome&ie=UTF-8#hl=en&sclient=psy-ab&q=good+PHP+book&oq=good+PHP+book&gs_l=serp.3..0l3.334576.339062.0.339506.13.12.0.1.1.1.843.4670.2-7j1j1j1j2.12.0.les%3B..0.0...1c.1._fM7Z9t-nzw&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.&fp=b367d9a11235c379&biw=1280&bih=899[^]
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

GeneralRe: learn phpmvpRichard MacCutchan27 Sep '12 - 5:41 
Very interesting, but if you had read the entire thread you would see that the OP lost interest a week ago.
One of these days I'm going to think of a really clever signature.

AnswerRe: learn phpmemberProgramFOX5 Oct '12 - 5:40 
Here you can learn php:
http://www.w3schools.com/php/[^]
Questionhow to implemet a php code on server side?membererroloz28 Jul '12 - 8:21 
We have a little php code and we wish to put that php code on server side but don’t know how!
 
The php code is ready, see it below:
 
If ($_POST["booking.php"]) { $iFrameURL = $_POST["booking.php"]; $i = 0; foreach($_POST as $key => $value) { $i++; if($i == 1) { $iFrameURL .= "?"; } else { $iFrameURL .= "&"; } $iFrameURL .= $key."=".$value;} }
?>
 
If you please tell me how to put this code on server side then I can do it too!
 
How to I implement this code on server side on my hosting?
 
where do i paste this code to or copy this code or as page and then what?
 
Thanks so much?
 
Oz
AnswerRe: how to implemet a php code on server side?memberenhzflep28 Jul '12 - 8:32 
Without knowing what exactly you're trying to achieve, it's a little hard to be specific.
 
Though, at a glance I'd say you want to do a GET via FTP to grab the file you'd like to put it in, followed by pasting the code into it, lastly by doing an FTP PUT to upload the modified file.
 
I'm assuming that it's an offsite hosting - that is to say, that it's a remote machine & not your dev machine.
 
You'd want to put it into whichever file made use of the variable $iFrameURL.
GeneralRe: how to implemet a php code on server side?membererroloz28 Jul '12 - 8:37 
hi and thank you so much for help.
 
we have a website and we implement s travel booking system and when some one want to search a flight from http://milleniumtravel.ca/booking[^] then he should get the result on result page which is http://milleniumtravel.ca/result[^] for this reason we need to put the code i mentioned on the server side. DomainMecca.com hosing.
 
I will appreciate if you help me with this and i can even pay you fro your help.
 
please let me know so i can give you our FTP info. I will be doing this today so its kind a important.
 
thank so much
 
Oz
GeneralRe: how to implemet a php code on server side?memberenhzflep28 Jul '12 - 8:49 
No worries mate. Just a word of advice - offers of money are generally poorly received on the forums here at CP, that'd be why you got 1 voted. Private email is less likely to offend.
 
Anyhow, it would seem that you just want to drop the code into the top of result(.php?) EDIT: /result/index.php (?)
 
So booking.php will have a form in it, with a field whose value is 'booking.php', perhaps something like so:
<form action='http://milleniumtravel.ca/result'>
 <input type='hidden' name='booking.php'/>
</form>
 
Along with a several other inputs to pass the data that you're then turning into a url.
 
Does this help?
GeneralRe: how to implemet a php code on server side?membererroloz28 Jul '12 - 8:58 
sorry about that, i wasn't sure how your forum really work. Thank yo for the advice Smile | :) I appreciate it very much.
 
my booking page in my word press site has: <iframe id="ifResults" style="margin: 100px; width: 1020px; height: 1020px;" src="http://milleniumtravel.ca/full_html_SV_form_gt"></iframe>
and
 
my result page in my WordPress site have; <iframe id="ifResults" style="margin: 100px; width: 1020px; height: 1020px;" src=""></iframe>
 
the actual booking company asked me to put this code:
 
<?php
If ($_POST["booking.php"]) { $iFrameURL = $_POST["booking.php"]; $i = 0; foreach($_POST as $key => $value) { $i++; if($i == 1) { $iFrameURL .= "?"; } else { $iFrameURL .= "&amp;"; } $iFrameURL .= $key."=".$value;} }
?>
 
on the server side and i honestly don't know how to copy and paste this code on the server side or where to paste it or do i need to create a page in my word press and name it what then where do i copy and paste this page if i create one etc...
 
i am all lost and the booking company told me that have no clue about php but they are the .net guys and they are rally arrogant and choose to not help!
 
i can give you my WordPress site login info or ftp if you would like to help me on this.
 
I have done intensive research online and i cannot find any one knows what i am trying to achieve despite i have told them exactly like on this page.
 
Thank you so very much.
 
Oz
GeneralRe: how to implemet a php code on server side?memberenhzflep28 Jul '12 - 9:17 
No stress, it does catch some people out that are unfamiliar with the customs. It seemed likely to be through lack of knowledge, rather than lack of caring, hence the friendly tip. Smile | :)
 

Cool, that extra information is most helpful. Perhaps we an even get the problem sorted owt for ya!
 
I'm not familiar with wordpress, so I before I go on, I'll say that I'm assuming it's a php page that has the code:
<iframe id="ifResults" style="margin: 100px; width: 1020px; height: 1020px;" src=""></iframe>
 
Whichever file that is, you need to edit that one. Put the php code they've supplied you with somewhere before the code for the iframe.
 
Next, edit the iframe code so that it includes your variable $iFrameURL, like so:
 
<iframe id="ifResults" style="margin: 100px; width: 1020px; height: 1020px;" src="<?php echo $iFrameURL;?>"></iframe>
 
This will put whatever is in the variable into the page as a string, to be used as the src of the iframe.
 
So, not knowing wordpress, I don't know if you can access(download & upload) the file
using your browser, or if you need to use ftp. I'm also unaware of whether it's php or asp, logically I expect it to be php, but I'm not going to bet a body part on it!
 
- Just seen an email notification that mention the pdf page. You've condensed the important information well - I can see nothing there that's useful to me with regards to this.
 
Here's an more-or-less unrelated question that demonstrates
1) setting a php variable to hold some info
2) using that variable in a page in the same way as I have here - using the echo statement. (note that it's a single file, with the php stuff before the html)
how to disable a button after click in php[^]
 
Everybody starts out new at sometime!
GeneralRe: how to implemet a php code on server side?membererroloz28 Jul '12 - 9:27 
hi,
 
thanks for your help.
 
the wordpress is a cms and has its own admin panel.
 
i have endtered the code on ifram age and name it test: http://milleniumtravel.ca/test[^] but it's not working.
 
Can you please simply tell me how one would put a php code on a server side?
 
is there a place on a hosting server where i can enter this code:
 
<?php
If ($_POST["booking.php"]) { $iFrameURL = $_POST["booking.php"]; $i = 0; foreach($_POST as $key => $value) { $i++; if($i == 1) { $iFrameURL .= "?"; } else { $iFrameURL .= "&amp;"; } $iFrameURL .= $key."=".$value;} }
?>
 
how one would enter this code on server side?
 
a- as a code as it is if so then where can i paste this code to on the server side?
 
b - create a php page and enter this code and save it and name it such as "page.php" and after use ftp and upload to somewhere but WHERE?
GeneralRe: how to implemet a php code on server side?memberenhzflep28 Jul '12 - 9:48 
The way you've entered the code on the test page is as content, rather than source code - i.e the code has been copied into the visible part of the page. You need to be able to edit the page directly, rather than just using whatever editing tool it offers.
 
If you look at the source code for the test page, we can see that the editor has altered your code, commenting out the opening tag of the php block. Also, it's dumped it into a paragraph tag
    <p>
      <!--?php<br /-->
      If ($_POST["booking.php"]) { $iFrameURL = $_POST["booking.php"]; $i = 0;
      foreach($_POST as $key =&gt; $value) { $i++; if($i == 1) { $iFrameURL .=
      “?”; } else { $iFrameURL .= “&”; } $iFrameURL .= $key.”=”.$value;}
      }<br>
      ?&gt;
    </p>
 
Since the page is displayed when the url is http://milleniumtravel.ca/result I'd guess that there's an index.php page inside that folder.
 
But it's really a bit hard to tell, since URL re-writing can map an address like that to something entirely different.
 
I'm sorry I can't provide better help. I'm certainly willing to, I just don't know how!
 
How did you create the test page? Was that from scratch/copy-paste, or was it via some kind of online editor? If it's an editor, then I've really got 3/5th and 5/8ths of no idea. Sigh | :sigh:
 
I've been up for about 17 hours now, so am far from my sharpest - though I guess I _could_ have a look around in the back-end if you really like.
 
Just send me another private email with some login details and I'll have a look for you - I must be in a good mood!
GeneralRe: how to implemet a php code on server side?memberl a u r e n16 Sep '12 - 23:09 
this is really bad coding practice anyways so maybe it's better it doesn't work?

"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"

AnswerRe: how to implemet a php code on server side?memberpragash smile8 Aug '12 - 4:45 
i wanna site to create using php
QuestionCan Anybody help me in SMTP for Bulk Emailingmemberucsinfotech1220 Jul '12 - 18:11 
Hi All,
Can Anybody help me in SMTP Setup for Bulk Emailing in PHP Programming.
 
Regards
www.ucsinfotech.com
AnswerRe: Can Anybody help me in SMTP for Bulk EmailingmvpRichard MacCutchan20 Jul '12 - 22:39 
Some suggestions[^].
One of these days I'm going to think of a really clever signature.

SuggestionRe: Can Anybody help me in SMTP for Bulk EmailingmemberMohibur Rashid18 Sep '12 - 15:14 
You want to send thousands of email with php? in this case you will have to ensure you don't do it web command base. you will have to execute your php code from your server using shell command. better yet crontab
I wish I could believe there is an after life.

Generalproblem with a query and not sure why... [modified]memberMacRaider420 Jul '12 - 7:35 
This is the code I'm having a problem with:
//$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM " . TBL_MEMBERS . " ORDER BY $order LIMIT :startRow, :numRows";
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM " . TBL_MEMBERS . " ORDER BY $order LIMIT $startRow, $numRows";
				
try {
  $st = $conn->prepare( $sql );
  $st->bindValue( ":startRow", $startRow, PDO::PARAM_INT );
  $st->bindValue( ":numRows", $numRows, PDO::PARAM_INT );
  echo "sql string = " . $sql . "<br />";
  echo "just before we hit the execute<br />";
  $st->execute();
  echo "just hit the execute<br />";
  $members = array();
  foreach ( $st->fetchAll() as $row ) {
    echo "pre";print_r($row);echo "/pre";
    $members[] = new Member( $row );
    echo "pre";print_r($members);echo "/pre";
  }
ok had to remove the <> from the pre tags to makes it easier to read...
 
Ok, if I run the non-commented out version of the SQL it works fine and I get the result I expect, however if I run the commented out version I get the following error:
 
Query failed 1: 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 ''5'' at line 1
 
I printed this out at the start of the function to check the values:
 
startRow = 0 and numRows = 5
 
I'm sure it's something stupid as I only spend about 5 - 10 hours a month doing PHP, so thank you in advance!
 
oh yeah:
 
mysql> select version();
+-------------------------+
| version() |
+-------------------------+
| 5.5.24-0ubuntu0.12.04.1 |
+-------------------------+
1 row in set (0.00 sec)

modified 20 Jul '12 - 13:55.

AnswerRe: problem with a query and not sure why...memberMacRaider423 Jul '12 - 8:53 
I figured it out... I checked the type of the variables and it thought the second was a string D'Oh! | :doh: so I made some code changes and it's now a INT. Love those descriptive error messages, guess they have learned a few things from M$
Generalhow to rebind a port in socket programmingmemberdesatir731615 Jul '12 - 2:53 
hi there
how can i rebind and reuse a port that i make it busy in perior session?
 
in typical we close a busy port with socket_close() in php but when i click on X button on my browser for exit, the port left busy and i cant use it for next time.
by the way how can i close a socket when user click on X button for exit?
 
Thank you for your thoughts on this
GeneralRe: how to rebind a port in socket programmingmemberdesatir731617 Jul '12 - 2:04 
i could not solve my problem Frown | :(
no body can help me?
GeneralRe: how to rebind a port in socket programmingmemberBobJanova17 Jul '12 - 3:43 
I don't think you understand how client/server HTTP applications work. You cannot tell when a browser disappears, because HTTP is stateless and request/response based.
 
And if you're opening sockets in the server side code you're almost certainly doing something wrong. PHP is not the right tool for a stateful persistent TCP connection.
GeneralRe: how to rebind a port in socket programmingmemberdesatir731617 Jul '12 - 4:35 
thanks for your reply BobJanova
i solve my problem with this code:
<?php
$fp = fsockopen("127.0.0.1", 26002, $errno, $errstr, 30);
 
    fclose($fp);
 
?>
by this i could close my last open port, maybe is not a good solution
i found it here:http://php.net/manual/en/function.fsockopen.php[^]
 
PHP is not the right tool for a stateful persistent TCP connection.
so, what is good for do this?
and what are the chatroom that creates on php?
Generalwhere to start for create a chat system in php? [modified]memberdesatir731612 Jul '12 - 5:52 
hi there
im new in php and want to create a chat server/client service for my project
 
so, do i have to start from socket programming in php for start?
what topics i must know?
 
should I use a specific framework like cake , zend , ... or it is soon to use theme?
 
by the way does php/mysql has offline help like msdn for asp or sth like SQL SERVER help?
 
please help me
thanks so much

modified 12 Jul '12 - 13:17.

GeneralRe: where to start for create a chat system in php?memberdesatir731612 Jul '12 - 8:16 
excuse me but why nobody answer me?
i need your helps
plz answer me
tnx
AnswerRe: I found sthmemberdesatir731612 Jul '12 - 9:01 
ok
i found sth that may can help:
Socket Programming in PHP[^]
GeneralRe: where to start for create a chat system in php?memberAndyInUK13 Jul '12 - 3:05 
Welcome to php world!
 
Here you will find many examples of what you are trying to achieve, but you got to look for the best rated one -
 
chat app[^]
 

It will be too early for you to use any framework.
 
Yes, you can download php manual here - php manual download[^]
 
Hope this helps!
GeneralRe: where to start for create a chat system in php?memberBobJanova13 Jul '12 - 4:53 
You almost certainly want to use AJAX for this, and some form of data store for the 'chatrooms'. That way it will work in browsers and be resource-light. Alternatively, if you want a client/server non-HTTP chat, you don't want to be using PHP to write it.
GeneralRe: where to start for create a chat system in php?memberdesatir731614 Jul '12 - 23:35 
thanks so much
BobJanova wrote:
, if you want a client/server non-HTTP chat, you don't want to be using PHP to write it.

but my project title is "create a server/client chat service in php"
this is why that i want to create it in php
GeneralRe: where to start for create a chat system in php?memberenhzflep15 Jul '12 - 0:07 
BobJanova wrote:
if you want a client/server non-HTTP chat, you don't want to be using PHP to write it.

I hope you'll find the above added emphasis clears your doubt.
GeneralRe: where to start for create a chat system in php?memberBobJanova17 Jul '12 - 3:47 
Server/client does not mean persistent TCP. A website over normal HTTP is client/server as well. And that is definitely the road you need to go down for a chat website. Here's an article[^] which might help you, or you can sample one of the others a famous search engine returns for 'ajax chat php'[^].
QuestionWritng a non-database specific code in PHPmemberawedaonline11 Jul '12 - 3:12 
Hello guys;
 
I am from .NET background where I write data access code to any database platform using the DbFactory and the like.
 
I need a sample code that can connect to any database that all i need to supply is the database provider name, database name, user name, password, etc.
 
Thank you for your understanding and support.
AnswerRe: Writng a non-database specific code in PHPmemberPeter_in_278011 Jul '12 - 12:30 
PHP Manual
>> Function Reference
>> >> Database Extensions
>> >> >> Abstraction Layers
 
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

GeneralRe: Writng a non-database specific code in PHPmemberawedaonline13 Jul '12 - 4:26 
Thank u Peter.
AnswerRe: Writng a non-database specific code in PHPgroupsali2212 Jul '12 - 18:13 
hi ,
if you want to connect to the Mysql database you can use the below code to connect and select your database
 

<?php
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("test") or die(mysql_error());
echo "Connected to Database";
?>

GeneralRe: Writng a non-database specific code in PHPmemberawedaonline13 Jul '12 - 4:27 
I truly appreciate your response.
QuestionProtecting PHP MailingmemberMike-MadBadger6 Jul '12 - 12:44 
Ah the joys, 9 million pieces of advice, guidance and code and not one agrees with another.
 
So I spent some time reading around and checking out the source for PEAR Mail and PHP Mailer and this is what I've managed to surmise - bearing in mind I am a beginner in most things and definitely in PHP, regex etc. (and essentially at zero when it comes to RFC822, SMTP etc. etc.)
 
What I really want to understand (rather than simply solve) is how to best protect a web contact form from being used maliciously.
 
Based on my limited understanding, one approach might be this - so, is it good, bad, misleading, wrong or (and this would be a surprise) not half bad?
 
1/ First use filter_var twice, once with FILTER_SANITIZE_EMAIL and then FILTER_VALIDATE_EMAIL on the from address only (since we supply the to address)
 
2/ Optionally use the PHP Mailer regex as belt and braces, again on the from address only ->
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
3/ Optionally test user data such as subject, name etc. (anything that goes in the header) with the regex from phundamentals ->
function safe( $name ) {return( str_ireplace(array( "\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );}
 
4/ Then build the headers array and use string replacement or preg_replace to remove line endings
5/ This could be as simple as the PHP Mailer string replace -> ("\r", "\n") or the more 'complex' PEAR Mail preg_replace ->
=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i
which appears to define extra descriptions of an EOL - for PHP v5+, could use str_ireplace instead of preg_replace
 
For reference here are the notes I made that led to my uninformed and speculative ideas above:
 
// Functions found from various sources
 
// www.nyphp.org/phundamentals/8_Preventing-Email-Header-Injection
// Pattern for filtering email addresses       --  '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i'
// Pattern for filtering fields such as names  --  '/^[a-z0-9()\/\'":\*+|,.; \- !?&#$@]{2,75}$/i'
function safe( $name ) {return( str_ireplace(array( "\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );}
 
// www.dreamincode.net/forums/topic/228389-preventing-php-mail-header-injections/
$reply_to = filter_var($reply_to, FILTER_VALIDATE_EMAIL);  if(!$reply_to) {...}
function sanitize(&$array) { foreach($array as &$data) $data = str_replace(array("\r", "\n", "%0a", "%0d"), '', stripslashes($data)); } } 
 

// PHP Mailer
// code.google.com/a/apache-extras.org/p/phpmailer/source/browse/trunk/class.phpmailer.php
// interesting to note that only FILTER_VALIDATE_EMAIL is used, FILTER_SANITIZE_EMAIL is not used
if (function_exists('filter_var')) { //Introduced in PHP 5.2
    if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
        return false;
    } else {
        return true;
    }
} else { 
    return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}
public function SecureHeader($str) { return trim(str_replace(array("\r", "\n"), '', $str)); } 
 

// PEAR Mail
function _sanitizeHeaders(&$headers)
{
    foreach ($headers as $key => $value) {
         $headers[$key] = preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i', null, $value);
    }
}
 
Mike
AnswerRe: Protecting PHP MailingmemberBobJanova11 Jul '12 - 23:49 
SMTP is a text format with CRLFs (line breaks) used in the header section. So make sure nothing which the user enters for the header section (probably just an email address) contains a line break.
 
Then, if you're using simple text format, the message is ended by a dot on a line on its own. So make sure the message doesn't contain that, or use a multipart format where you set the boundary (and, obviously, pick something which doesn't occur in the text).
GeneralRe: Protecting PHP MailingmemberMike-MadBadger13 Jul '12 - 22:05 
Thanks for the reply.
 
That recommendation is in quite a few places but if it's so simple why do PHP Mailer and PEAR Mail (for example) do far more than just that?
 
I'm assuming the developers aren't dim so there must be a reason for it - that's what I'm trying to understand.
 
Mike
GeneralRe: Protecting PHP MailingmemberBobJanova17 Jul '12 - 3:42 
In short they are sanity checking for valid input (i.e. trying to determine that an email address is valid), not just protecting you from service abuse (i.e. using features of the protocol to make the system do something unexpected).
GeneralRe: Protecting PHP MailingmemberMike-MadBadger19 Jul '12 - 6:58 
Thanks for sticking with me (and the long delays between replies).
 
So, given that this is an age old problem, how come they both take different strategies to sanity checking and injection prevention? You'd have thought that for such a well known issue there's almost be an industry 'standard' approach for both issues and which is optimised in every which way, well tested and verified etc. For two of the major OS projects delivering this functionality to be taking different approaches / models seems kinda odd - you know, learn what is best from each other and slowly but surely they coalesce onto the exact same code.
 
Also interested to know if you add the 'correct' rules to Quickform2 then do you get the same / better / worse sanity / injection checking that PHP Mailer and PEAR Mail provide?
 
Thanks again,
Mike
Generalwhy does this not work? [modified]membergeoman298z6 Jul '12 - 7:29 
session_start();
 
$con = mysql_connect("database","uername","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
 
mysql_select_db("database", $con);
 

 
mysql_query("UPDATE users SET money=money+1000 WHERE username = '". $_SESSION['username']."'");
echo $_SESSION['username'];
 
mysql_close($con);
?>

 
please help!
 
this is the errors
 

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/12/8488612/html/users/1000.php:2) in /home/content/12/8488612/html/users/1000.php on line 3
 

 
Warning: Cannot modify header information - headers already sent by (output started at /home/content/12/8488612/html/users/1000.php:2) in /home/content/12/8488612/html/users/1000.php on line 20

modified 6 Jul '12 - 13:39.

AnswerRe: why does this not work?mvpLuc Pattyn6 Jul '12 - 10:49 
A number of operations can not be performed once the HTML header has been opened; session_start() should be called well before anything else that generates HTML code, such as a simple echo "Hello".
 
As a test, comment out session_start() and see what gets emitted, that is likely to tell you where you went wrong.
 
And why was your message type "General", rather than "Question"?
 
Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

AnswerRe: why does this not work?membernirangad12 Jul '12 - 0:36 
Are you including this PHP file inside another file? if so make sure that include statement is the first statement in that file
Niranga De Silva
Software Engineer @ 99X Technology

GeneralRe: why does this not work?groupsali2212 Jul '12 - 18:18 
Perhaps you have used Unicode for designing your webpage,
beside that "session_start()" must be the first line of your web page . so some times one code has been added to the page for encoding purpose. it's better to use standard PHP editor like "Zend Studio" to see and remove this code before session_start()
GeneralDatabase Question [modified]memberBaddy_Bad_Boy6 Jul '12 - 0:59 
Hi
 
I am new to linux and was supposed to use Database.
 
I don't no much about that.
Can anyone please tell me how can I create, insert, update and delete   data from a database.
 
Thanks in advance

-- modified 6 Jul '12 - 7:16.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 21 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid