cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, if you run the query in a MySQL client as command line or PHPMyAdmin do you get results?

If the answer is yes, then are you sure that $_GET['pagination'] is correctly populated by your .htaccess rewrite rules?

To test it just try:

print_r($_GET);

to see the contents of this array.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, what's your current code?

Consider that you should change the code block that returns the results by removing the echo and the die constructs and by replacing them with return:

if(($result = $this->sendMail($to, $subject, $body, $headers)) === TRUE)
    return json_encode(['success' => true]);

else
    return json_encode(['error' => $result]);

Consider that the die construct stops also the execution of the calling script, so when you include your mailer class into another file it will not return all the expected output, which is not good for production. This construct should be used when you have to debug code.

By the way, if you don't want to show error details then you can also change the IF statement to something simplier:

if($this->sendMail($to, $subject, $body, $headers))
    return json_encode(['success' => true]);

else
    return json_encode(['error' => 'something really wrong just happened']);

And switch back to a boolean return in sendMail():

return $mail->Send();
cereal 1,524 Nearly a Senior Poster Featured Poster

Do I need to configure something in xampp when I'm still using PHPMailer

No, the error seems related to the SMTP server.

As long SMTP server, port number and credentials are correct then you should be able to send the message, at the moment it seems that the connection attempt timeouts, is the SMTP server url correct?

Make sure these values are correct, especially Host and Port:

$mail->Host = 'stmp.emailsrvr.com';
$mail->Username = 'gideon.a@scopicsoftware.com';
$mail->Password = '*******';
$mail->Mailer = 'stmp';
$mail->Port = 25;
$mail->SMTPAuth = true;
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, try to change the LIKE condition to:

LIKE '".$item."%'

By adding the % wildcard you can match similar text:

If it still does not work test your query directly into a MySQL client. Besides: escape also feedTipo.

cereal 1,524 Nearly a Senior Poster Featured Poster

Sorry, I forgot to set the boolean check in:

if($result = $this->sendMail($to, $subject, $body, $headers)) {

Change it to:

if(($result = $this->sendMail($to, $subject, $body, $headers)) === TRUE) {

And it will show the success message only when sendMail() explicitly returns boolean TRUE.

In reference to the error message switch the debug level to 3 to get more information. But I think it's due to the $headers argument, you are setting setFrom() with the sender email address.

Instead use the email that authenticates within the SMTP server, you are not authenticating the sender so you cannot use it in the FROM header. Set the sender email address in AddReplyTo(), so:

$mail->setFrom('gideon.a@scopicsoftware.com');
$mail->AddReplyTo($headers);
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

Add to the sendMail() method:

$mail->SMTPDebug = 2; # switch to 3 or 4 to increase verbosity

Then change the return of the sendMail() method to:

if( ! $mail->Send())
    return $mail->ErrorInfo;

return TRUE;

And in actionSendMail() replace the previous sending mail code block with:

//Sending mail 
if($result = $this->sendMail($to, $subject, $body, $headers)) {
    $response = json_encode(['success' => true]);
    echo $response;
} else {
    $response = json_encode(['error' => $result]);
    die($response);
}

Now you should be able to read what is sent to the SMTP server and see why it fails.

cereal 1,524 Nearly a Senior Poster Featured Poster

The browser javascript console does not return any error? Can you show your code?

diafol commented: heh heh. blood from a stone. everytime +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you could use an each loop:

$('#updated_status').on('change', function () {
    var e = $(this).val();
    $.each(feedit, function (key, val) {
        if (e == val.value) {
            $('#comments').val(val.areatext);
        }
    });
});

Live example: http://jsfiddle.net/o3g8sp6c/

diafol commented: Simple - just as it should be. Nice. +15
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

Dani the reward system is showing the wrong information:

screen.png

The available points should be around ~1100 not 3363. Last cash out information instead is correct.

cereal 1,524 Nearly a Senior Poster Featured Poster

The jsfiddle example makes use of an external resource along with jQuery:

By adding this it should work.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hmm, I'm not sure I've understood your request.

Let's try: you have to define the image in the destination page, which can be done with a static or a dinamic approach.

When using a static method just create the page that will show a pre-defined image:

page.photo01.html

And point the browser to that specific page.

When using a dynamic method you create a container, a page that can elaborate and display the contents accordingly with the sent input.

The input can be sent by using GET and POST methods, which are HTTP verbs to access web resources. Below I'm going to show you a simple GET request approach:

You have to set a query string to the opening link so you can send the file name, for example:

<a href="page.php?img=photo01.jpg">
    <img src="/images/photo01.jpg">
</a>

Note page.php?img=photo01.jpg in the href attribute, you have to use a PHP file (or another server side scripting language), because you need to access the query string parameters.

So, in the page.php file you write something like this:

<?php

    $img   = array_key_exists('img', $_GET) ? basename($_GET['img']) : FALSE;

    # web path, used to display the file in the browser
    $path  = '/images/';
    $image = $path . $img;
?>
<!DOCTYPE>
<html>
...

<!-- display image here -->
<?php
    # display the image
    if($img) echo "<img src=\"{$image}\">";

    # default image (not required)
    else echo "<img src=\"/images/default.jpg\">";
?>

If you don't want to use server side languages, you can go with Javascript and read the …

cereal 1,524 Nearly a Senior Poster Featured Poster

Depends on the structure of the array and the data type, you could use implode() to flat the array to a string:

$a = ['a' => 123, 'b', TRUE, 'c', NULL, 'd', 'e' => [1,2,3]];
print_r(implode(', ', $a));

# returns 123, b, 1, c, , d, Array

But as you see: you loose the index key a, with booleans and null you get a conversion and the nested array is converted to Array, not showing the data.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you show the exact error message and code number?

cereal 1,524 Nearly a Senior Poster Featured Poster

Haven't used CI in years so can't remember if array variables passed to a view are extracted or not. You're passing $data['error'] and picking it up as $error in the view. Is this right? I can't remember.

Hi! Yep, that's correct, as long that you feed the $data array to the view, then the keys will be extracted and used as variables. ;)

@Ventech_IT
Code seems fine. What about the parse error?

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, use the href attribute to point the browser to the destination page:

<a href="another_page.html">Link to another page</a>

Some additional information:

Is this that you were searching for?

cereal 1,524 Nearly a Senior Poster Featured Poster

Assuming that $path is relative to the CodeIgniter main index.php file, then change path to:

$path = FCPATH . 'uploads/path/';

The constant FCPATH is defined in the index.php file. Then simply loop the $files array against unlink():

array_map('unlink', $files);

And that's all.

cereal 1,524 Nearly a Senior Poster Featured Poster

Is this the code of the http://localhost:8000/feedreader/fbindex.php script?

The redirect url MUST be the script that will receive the authorization code appended to the link, for example:

http://localhost:8000/feedreader/fbindex.php?code=AUTHORIZATION_CODE

The value of $_GET['code'] is read by:

$session = $helper->getSessionFromRedirect();

Which enables the Facebook Session by realesing an access token that you must save in some way, for example into a PHP session, otherwise, and this is important, when you browse to another page you will loose it.

In your current code it seems you are trying to save the access token before clicking the access link. Which is hidden because there is no Facebook session at the moment. So try:

if(isset($session))
{
    $_SESSION["access_token"]=$session->getToken();
}

else
{
    echo "<a href='".$helper->getLoginUrl()."'>Login with Facebook</a>";
}

And it should work.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

Try by setting two separated cURL requests that share the same connection. There is a comment in PHP docs that can be helpful:

NTLM authorization is connect-based, not request-based. If the connection is not kept alive and re-used, cURL can never complete the request.

So try:

$ch = curl_init($this->service . ".php");

# authentication
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_PROXY, $this->proxyServer);
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->proxyUPD);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_exec($ch);

# sending XML body
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlToSend);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);

By doing this the server should keep the connection alive. You can test it by using a shell with:

nc -l localhost 8080

The output in my test looks like this:

GET HTTP://run_ntlm.php/ HTTP/1.1
Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
Host: run_ntlm.php
Accept: */*
Proxy-Connection: Keep-Alive

And it stops because there is no proxy here. Maybe it can help you.

cereal 1,524 Nearly a Senior Poster Featured Poster

By using $session->getToken() you get the access token. For example when you perform the login request you use a script like this:

<?php

session_start();

require_once "credentials.php";
require_once "autoload.php";
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
use Facebook\FacebookRedirectLoginHelper;

$redirect_url = "http://localhost:8005/logged.php";

$helper = new FacebookRedirectLoginHelper($redirect_url, $appId, $appSecret);
echo '<a href="' . $helper->getLoginUrl() . '">Login with Facebook</a>';

The logged.php file in the redirect url is this:

<?php

error_reporting(-1);
session_start();

require_once "credentials.php";
require_once "autoload.php";
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
use Facebook\FacebookRedirectLoginHelper;

$redirect_url = "http://localhost:8005/logged.php";

FacebookSession::setDefaultApplication($appId, $appSecret);
$helper       = new FacebookRedirectLoginHelper($redirect_url);

try {

    $session = $helper->getSessionFromRedirect();

    if(isset($session))
    {
        # save token to PHP session
        $_SESSION['access_token'] = $session->getToken();

        # show some text
        echo "<p><a href=\"get.php\">Perform a GET request</a></p>";
    }
}

catch(FacebookRequestException $e) {
    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();
}

catch(\Exception $e) {
    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();
}

Which is where you are redirected by Facebook. Then you browse to another page (in the example this is get.php) where you read the token from the PHP session and perform a request against Facebook:

<?php

error_reporting(-1);
session_start();

require_once "credentials.php";
require_once "autoload.php";
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\GraphObject;
use Facebook\GraphSessionInfo;
use Facebook\FacebookRequestException;

FacebookSession::setDefaultApplication($appId, $appSecret);

# Get the token from PHP session:
$session = new FacebookSession($_SESSION['access_token']);

$user_profile = (new FacebookRequest($session, 'GET', '/me'))
                ->execute()
                ->getGraphObject(GraphUser::className());

echo "Name: " . $user_profile->getName();

Note: by using the autoload.php file released in …

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition: maybe you could use cipher.exe, read here:

savedlema commented: Ok, thank you. +2
cereal 1,524 Nearly a Senior Poster Featured Poster

It happens if you browse to another page and do not save the access token you got from the login request. If you're not using the Javascript SDK along with PHP, then you have to save the token in server side, for example in PHP Session:

# after login
$_SESSION['access_token'] = $session->getToken();

So when you browse to another page and load the request you can do:

$session = new FacebookSession($_SESSION['access_token']);

$user_profile = (new FacebookRequest($session, 'GET', '/me'))
                ->execute()
                ->getGraphObject(GraphUser::className());

echo "Name: " . $user_profile->getName();

Note that for POST request you need specific permissions, docs:

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, go on Facebook > My Apps > happ > Settings click on Add Platform, choose Website and set Site URL to:

http://localhost/

In case you're using a port different from 80, then add it, for example:

http://localhost:8000/

Once you have saved the changes your script should work fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

What about App settings? When testing in localhost you don't have to define a domain. If you do so, the login process will fail.

A part that, when you click the login link do you reach Facebook at least? The problem starts when you are redirected to this link?

http://localhost/fullsoka/index.php
cereal 1,524 Nearly a Senior Poster Featured Poster

It could be a timeout from remote. The default value for timeouts is defined in php.ini file, but you could create a stream context to test the download:

$options["http"] = array(
        "method"    => "GET",
        "timeout"   => 15, # seconds
    );

fopen($attachment->URLNormalizedFile, "r", FALSE, $context);

Also check access and error logs from server and PHP.

but strangely a lot of images get corrupt, it's always the first image of the next xml file

Have you tried to manually access to the first entries of these XML files? Are these images reachable, have you tried a simple script to download just these files? Have you tried to open one of these files through an editor? Sometimes you expect binary but you find an HTML page (404 error pages for example).

By the way: why are you using fopen to get data into file_put_contents?

cereal 1,524 Nearly a Senior Poster Featured Poster

So what happens, in your code, when you switch between the xml files? Can you show the code?

cereal 1,524 Nearly a Senior Poster Featured Poster

Your code works fine for me with my app settings, try to add error_reporting(-1); to the top of your script and see if it returns any error, warning or notice.

cereal 1,524 Nearly a Senior Poster Featured Poster

Add echo $ex->getMessage(); to the catch statement:

catch(Exception $ex)
{
    echo $ex->getMessage();
}

If something is wrong you should get some information that will help you to debug.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, try:

find /home/scott/xyz -name "*.log" ! \( -name "access.log" -o -name "server1.log" \)
cereal 1,524 Nearly a Senior Poster Featured Poster

Also, have you checked if the file is loading through the browser console? On Google Chrome press CTRL + SHIFT + J then go to the Network tab and reload the page, check if the css file loads with 2xx or 3xx status codes.

cereal 1,524 Nearly a Senior Poster Featured Poster

Try to add the (root) slash to the link:

<link
    rel="stylesheet"
    type="text/css"
    href="/resources/css/docTech25Banner.css" />

Otherwise the link will be relative to the current path, if you are in /contact/, for example, the browser will expect to find the css file inside:

/contact/resources/css/docTech25Banner.css

And so on for each browsed path of the website.

cereal 1,524 Nearly a Senior Poster Featured Poster

@jaiuriyal

Which is the value of $email_from? A GMail account? The From header MUST be an email address that you can authenticate against an SMTP server. If using a free hosting then this is not the issue, as they will replace the headers. The same if you set sendmail properly.

Here you have to set two headers From and Reply-To:

  • From with your email
  • Reply-To with the value of $_POST['email']

The thread I linked explains the issue and it is linked to another thread with more information. Please take time to understand how it works.

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, try group_concat() with group by:

SELECT group_concat(Description) FROM tablename GROUP BY Section;
cereal 1,524 Nearly a Senior Poster Featured Poster

@philjen

Hi, OP asks if he can use set_value() to return the uploaded file path when going back to the form due, for example, to the validation process.

The function set_value() will not work with an input file type tag because of the HTML specification and because browsers do not allow to preset a value for this type of input field.

In practice:

<input type="file" name="image1" value="/path/to/file.jpg" />

does not work. The value attribute is not accepted.

Alternative: when the form is submitted, if the validation does not fail because of the file but due to another input field, he can save the file and when going back to the form, show the file a part. Like an attachment, with the option to replace it.

Also note that Ellislab does not support anymore CodeIgniter, from now on you should refer to:

cereal 1,524 Nearly a Senior Poster Featured Poster

This is caused by the comment between the short tag and the assignment operator =:

<?/*hi*/='hello';?>

which should look like this:

<?='hello';?>

This is the same of writing:

<?php echo 'hello'; ?>

When possible try to avoid short tags as on versions previous to PHP 5.4 are not always available: http://php.net/manual/en/language.basic-syntax.phptags.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Yup, change the value of the LANGUAGE_CODE constant, this is probably set in the config file included in the top of the script.

To verify if English is supported just check the ./lang/ directory, you should find a file like lang.admin.en.php, otherwise use one of the existing files in that directory to add the support.

Note: in linux file names are case sensitive.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, change TYPE with ENGINE and it should work.

TYPE has been removed from current syntax: https://bugs.mysql.com/bug.php?id=17501

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

at basic you should include the headers to define From and Reply-To, check example 2 of the documentation:

Where From is one of your emails and Reply-To the sender email and you will need a mailer application to send the message, like sendmail which is usually installed on linux and mac platforms. For windows I have no idea of which local solution you could use (maybe sendmail in cygwin?)

Additionally if your email requires the connection to an SMTP then mail() is not the best approach.

Pay attention to this point: if you're working on a script that will run on a remote server then check the hosting documentation (or ask to the support) if SMTP is required when sending an email from the registered domain. In that case read this thread:

In case the From header is populated by a gmail account, then SMTP is required, by not authenticating the script will fail.

And do a search on Daniweb, this argument has been discussed a lot of times.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

the best solution would be for example1.com to serve a page where all price changes are published, so that example2.com needs to query only one time and not X number of times... if you have 10000 articles it means you are going to open that amount of connections against example1.com.

The serving method could go from a simple REST API returning XML or JSON, or an RSS feed.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, you have to use set_value() from the Form helper:

Which basically works like this:

<input
    type="text"
    name="first_name"
    value="<?php echo set_value('first_name', 'default value'); ?>"
    />

Where the first argument is the value assumend by the form after a submission, so in case of POST data it will repopulate with the latest data. The second argument is the default value, this is optional, BUT this is where you set your database values, by applying a ternary operator:

As example the above PHP code changes to:

<?php echo set_value('first_name', ($row ? $row->first_name : '')); ?>

Where $row is the object (or the array) returning the value from the database, i.e. in your model you set something like this:

public function get_user($id)
{
    $this->db->where('user_id', $id);
    $this->db->limit(1);
    $q = $this->db->get('users');

    if($q->num_rows() > 0)
        return $q->row();

    return FALSE;
}

And in your controller:

public function index($id)
{
    $this->load->model('users');
    $data['row'] = $this->users->get_user($id);

    $this->load->view('view', $data);
}

In my example:

$row ? $row->first_name : ''

works because in the model I set boolean FALSE when the database returns 0, and the implicit condition is like writing:

if($row !== FALSE)
    echo $row->first_name;
else
    echo ''; # default value

but you can change the condition to check if it is an object or an array. It's up to you.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

try to add ORDER BY unit_cm DESC LIMIT 3 to the subquery and remove min() from the main query.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

you cannot do this, the HTML specification does not allow to set a value for the input file type element. Otherwise a website could try to access to any file in the local system of the client.

Here you can see the attributes that you can set:

cereal 1,524 Nearly a Senior Poster Featured Poster

You can set a cron job that calls a script that will execute the query to change the status, or if using MySQL you can use the event scheduler of the database, for more information read these links:

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

I guess you are mixing things here: when you submit input through a form, you get a string, so here you are going to parse a string not a variable, only by evaluating the string you could execute it and get the variable value, but this is risky because the client can execute whatever.

You could use preg_match to match the assignment operator (=) but in PHP you can write variables like these:

${'a=b'} = 'hello';
$a = $b = $c = 'hello';

And it becomes very difficult to match the correct value: hello, instead of b/$b/$c.

I think a better approach is to use token_get_all():

But it requires a little workaround, you have to prepend the opening tag <?php to the received input otherwise it will parse it as HTML.

An example:

<?php

    $input  = '$a = "hello"';
    $input  = '<?php ' . $input;
    $parsed = token_get_all($input);
    $result = '';
    $tokens = array(
        T_DNUMBER,
        T_ENCAPSED_AND_WHITESPACE,
        T_LNUMBER,
        T_NUM_STRING,
        T_STRING
        );

    foreach($parsed as $key => $value)
    {
        if(is_array($value) && in_array($value[0], $tokens))
        {
            $result = $value[1];
            break;
        }
    }

    echo $result;

Which returns hello.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,

geopy.exc.GeocoderServiceError: HTTP Error 500: Internal Server Error

from documentation of geopy you can read the meaning of this exception:

There was an exception caused when calling the remote geocoding service, and no more specific exception could be raised by geopy. When calling geocoders’ geocode or reverse methods, this is the most general exception that can be raised, and any non-geopy exception will be caught and turned into this. The exception’s message will be that of the original exception.

HTTP Error 500 is a generic server error: http://httpstatus.es/500

So, it seems the problem is generated by the provider, i.e. by the Nominatim server.

cereal 1,524 Nearly a Senior Poster Featured Poster

Heh! Good for you, at your age I barely knew about HTML...

It's like a fear to be intimidated by co-workers that I'm a novice or something like that.

Never fear, just be keen to learn from others. It can only improve your skills.

Gideon_1 commented: thanks cereal +3
cereal 1,524 Nearly a Senior Poster Featured Poster

The third argument for update() must be a WHERE condition (for example: 'id = 4'), instead with update_batch() the third argument is the index key, so try to change your code to:

$this->db->update_batch('deal_images', $dataimages, 'merchant_deals_id');

And it should work.

cereal 1,524 Nearly a Senior Poster Featured Poster

Great, you're welcome. If we have finished, then please mark the article as solved. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome!

This $_POST['query + website']; cannot work, because there you're trying to access an index key, in order to work your array should look have an index key like in your test:

$a = array(
        'query'           => 'abc',
        'website'         => 'http://some.url/',
        'query + website' => 'def'
    );

echo $a['query'];
echo $a['website'];
echo $a['query + website'];

You can use string concatenation:

$message  = $_POST['query'] . "\n\r";
$message .= "Website: " . $_POST['website'] . "\n\r";

$this->Body = $message;

by prepending the assignment operator (=) with a dot (.) you append the new value to the variable instead of overwriting it. Which is the same of writing:

$message = $_POST['query'] . "\n\r Website: " . $_POST['website'] . "\n\r";

Note: double quotes are important to properly translate the linefeed (\n) and carriage return (\r) characters.

cereal 1,524 Nearly a Senior Poster Featured Poster

I don't see any errors or Warnings. Should I be concerned ?

If the value is set then the script may exit for another reason, it could be memory exhausted or something else, check the error log file of PHP or set:

error_reporting(-1);

To get all errors, notices and warnings.

Above here i faced a problem if I select 100+ HD Photos it takes only 20 of them and puts them in the Folder and keeps only those 20 Records .... This was due to "max_execution_time" <----- I think but I am not sure, as the script runs for about 10 seconds max !!!!

If you prepended any function with the error control operator @, for example @file('...') you will not see that specific error, so temporary remove them to debug the script.

If you still don't get any errors then, if possible, share your code, this will help us to understand the issue.

I am using PHP 5.1

If possible upgrade PHP to latest version, PHP 5.1 last update was in 2006. Not good.