Latest Posts in PHP

Re: in PHP
 
0
 

Okay for some reason I think I found the issue. The issue is with my SMTP server.

cereal I found these differences and when I switched SMTP servers the encoding was working correctly.

current server has issues with encoding

hello: 250-smtp1.myserver.com
250-SIZE 20480000
250 AUTH LOGIN
from: 250 OK
to: 250 OK


old server that doesn't have encoding issues.
hello: 250-mail2.oldserver.ca
250-PIPELINING
250-SIZE 50000000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 8BITMIME
Re: in PHP
 
1
 

Then check the contents of the debugger:

print_r($this->email->print_debugger());

You should be able to see the encoding, which is also visible looking at the headers of the received mail, but you should also be able to see if the connection to the SMTP server was done in UTF8 mode, for example:

250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8                 <- this
Re: in PHP
 
0
 

Tried both then re-sent the email same result.

htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|images|scripts|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]  
AddDefaultCharset utf-8
Re: in PHP
 
0
 

All fixed now.

I found a post with a similar problem here
Click Here

I added the chmod($emailDir.$attachment, 0777); line before unlink($emailDir.$attachment) and now it is working.

Doesn't make sense to me as no permissions warning was produced without the chmod and unlink() returned true and the file was deleted eventually but with a massive delay. Now it happens instantaneously.

Windows/WAMP issue? I don't know.

Re: in PHP
 
0
 

Hi, set the default charset for the web server to UTF-8, you can do this by adding this directive into your .htaccess file:

AddDefaultCharset utf-8

And be sure default_charset, in the php.ini file, is set correctly, otherwise set it dinamically:

ini_set('default_charset', 'UTF-8');
Solved in PHP
 
0
 

I'm not sure what the issue is. I've checked all my encodings and they are all set to UTF-8 and no matter what the emails come in weird text. Not everything just throws in a weird letter at the end of words for some reason.

Example of email

The Server has finished transcoding your file for you=. 

You can click on this This Link to view your file before downloadin=

Thanks,

Then here is my code. Everything looks fine to me. Doesn't matter if Windows or Mac still shows weird.

    $config = Array(
                'protocol' => 'smtp',
                'smtp_host' => 'my.smtp.server.com:25',
                'mailtype'  => 'html', 
                'CharSet'   => 'UTF-8');

            //set common email values
            $this->load->library('email', $config);
            $this->email->set_newline("\r\n");
            $this->email->subject('Completed Transcoding');

            $this->email->message("
            <html>
            <head>
            <style type='text/css'>
            tr:nth-of-type(odd) {
            background-color: #bdc8d2;
            </style>
            </head>
            Hello $uploader,<br><br>The Server has finished transcoding your file for you.
            <br><br>You can click on this <a href='#/$transcoding_id'>This Link</a> to view your file before downloading<br><br>
            Thanks,<br>
            Digital Transcoding Server<br>
            </body></html>");
    $this->email->to($RF->email);

    $this->email->send();
    echo "ok done";

Also my database is using utf8_general_ci. I also tried using a different text editor and same result.

Thoughts. Ideas?

Re: in PHP
 
0
 

I am using name, because there are multiple entries, so cannot just return the row ID

Re: in PHP
 
0
 

The value in the dropdown, is the name of the vlaue, not the ID, but, I see what you are saying...

Re: in PHP
 
0
 
<option name  = "techOption" value = "<?php $line['tech_name'];?>"><?php echo $line['tech_name']; ?> </option>

remove the name="techOption"

<option value = "<?php $line['tech_name'];?>"><?php echo $line['tech_name']; ?> </option>
Re: in PHP
 
0
 

I think you can use $j instead of $i in php

<script language="javascript">function addRow(tableID){var table=document.getElementById(tableID);var rowCount=table.rows.length;var row=table.insertRow(rowCount);var colCount=table.rows[0].cells.length;for(var i=0;i<colCount;i++){var newcell=row.insertCell(i);newcell.innerHTML=table.rows[0].cells[i].innerHTML;switch(newcell.childNodes[0].type){case"text":newcell.childNodes[0].value="";break;case"checkbox":newcell.childNodes[0].checked=false;break;case"select-one":newcell.childNodes[0].selectedIndex=0;break;}}}
function deleteRow(tableID){try{var table=document.getElementById(tableID);var rowCount=table.rows.length;for(var i=0;i<rowCount;i++){var row=table.rows[i];var chkbox=row.cells[0].childNodes[0];if(null!=chkbox&&true==chkbox.checked){if(rowCount<=1){alert("Cannot delete all the rows.");break;}
table.deleteRow(i);rowCount--;i--;}}}catch(e){alert(e);}}</script>

 <form method="post">

    <input type="button" value="Add Row" onclick="addRow('dataTable')">

    <input type="button" value="Delete Row" onclick="deleteRow('dataTable')">

    <table id="dataTable" width="350px" border="1">
        <tbody><tr>
            <td><input type="checkbox" name="chk[]"></td>
            <td><input type="text" name="txt[]"></td>
        </tr>

    </tbody></table>
    <br><br>
    <input type="submit" name="submit" value="submit">
</form>  

<?php
        if(isset($_POST['submit']) && $_POST['submit'] == 'submit')
        {

            $txtbox = $_POST['txt'];

            echo 'limit Count - '. $limit = count($txtbox).'<br>';

            for($j=0;$j<$limit;$j++)
            {
                echo $txtbox[$j].'<br>';

            }


        }


?>
Re: in PHP
 
0
 

You don't need to pass any info already stored in a session in the url unless you need it for SEO or are using it as part of an API (e.g. RESTful requests) as far as I can see. So, seeing as you have session_start() in every page (right?), you can just pluck the user_id from $_SESSION['user_id'] every time - no need for $_GET['id']. But perhaps I've got your use case wrong.

Re: in PHP
 
0
 

You should be getting/seeting the customer id in the dropdown value attribute no the actual name. So your HTML would look like...

<option value="2">BT Global</option>

To create would be something like...

<option> value="<?= $row['id'] ?>"><?= $row['customer'] ?></option>

in your select loop. You then pluck the id value and use that in your DB actions.

Re: in PHP
 
0
 

Hello Diafol,

Thanks for the careful observation in numbr 1 and 2. That will be my next move to develop this system. I am still researching ideas for better security.
I am much concern on your observation number 3. Can you please give me suggestions to correct those.

in PHP
 
0
 

I have a select box that looks up values from my database, and then runs a jquery function to display the results, function is working fine, but some of the values in the database have spaces i.e "BT Global" the results are returning everything that starts with "BT"

any help appreciated.

<?php
$sql = 'SELECT customer FROM device GROUP BY customer';
if(!$result = $db->query($sql)){
    die('There was an error running the query [' . $db->error . ']');
}
echo "<select class='form-control' id='fwname' onchange='getfirewall();'>";
echo "<option selected='Choose Customer'>Choose Customer</option>";
while($row = $result->fetch_assoc()){
$thevalue = $row['customer'];
echo "<option value=".$thevalue.">";
echo  $thevalue;  
echo "</option>";
}
echo "</select>";
?>`
Re: in PHP
 
0
 

I don't know if there is a ready PHP solution for this, but if you can install software in your hosting, then use LibreOffice in command line mode:

<?php

    $file = 'something.doc';
    $str  = sprintf("libreoffice --headless --invisible --convert-to pdf %s", $file);
    $cmd  = escapeshellcmd($str);

    exec($cmd);

There are other solutions as unoconv, based on LibreOffice and JodConverter which seems to not be anymore maintained.

Re: in PHP
 
-2
 

of course it is, unless clicking a mouse is the deal breaker. So strenuous fo the poor visitor! sounds like you are happy paying so dont ask for free ones or write your own. maybe you can get a commission from them

OP Kudos: in PHP
 
0
 

Hi,
I need a php code for converting from any format to pdf by clicking a button called convert to pdf.
How to do?

PHP Tag Cloud