cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe you have more than a row in your result set? Try:

echo $count;

To avoid this problem you can add limit to the query:

$sql ="SELECT * FROM `task_2` WHERE `username` = '$myusername' and `password` = '$mypassword' limit 1";
cereal 1,524 Nearly a Senior Poster Featured Poster

No problem, you are using quotes around the name of the table 'task_2':

$sql ="SELECT * FROM 'task_2' WHERE username = '$myusername' and password = '$mypassword'";

I suggested you to replace them with backticks otherwise it's treated as a value, so change the query line as here:

$sql ="SELECT * FROM `task_2` WHERE `username` = '$myusername' and `password` = '$mypassword'";

Spot the difference:

'task_2' <- wrong
`task_2` <- correct

In order to see the error use mysql_error():

$result = mysql_query($sql) or die(mysql_error());
cereal 1,524 Nearly a Senior Poster Featured Poster

Use backticks for table and field names, and quotes only for values as here:

$sql ="SELECT * FROM `task_2` WHERE `username` = '$myusername' and `password` = '$mypassword'";

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

cereal:

Italy only looked a shadow compared to the France game the weekend before. To be brutally honest, the number 10 was back to normal Italian 10 form against Scotland as in couldn't kick for toffee.

Don't get me wrong, I'm not anti-Azzurri (they have the legendary Castro after all - I'm a long-time Tigers fan) but the team still has a lot of problemns when it comes to playing mature and consistent rugby.

I completely agree, we have a lot of experience to gain.. I just hope we are not going to conquest the 10th wooden spoon.. :D

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, you need Ajax and a script to receive, save and return data from the form, FB uses also a cache to save data and return, here I create an example with JQuery framework, we are going to save it only to the database:

create table message_board(id int(9) not null auto_increment primary key, message varchar(255) not null, creation_date datetime not null) engine=myisam default charset=utf8;

The form page:

<?php

# ... connection string to database ...
$q = mysql_query('select * from message_board order by id desc');

?>
<!DOCTYPE html>
<html>
<head>
    <title>search</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){

        $('#myform').submit(function(e) {
            e.preventDefault();
            var mdata = $('#myform').serialize();
            console.log(mdata);

            // if searchString is not empty
            if($('#message').length > 0) {
                // ajax call
                $.ajax({
                    type: "POST",
                    url: "save.php",
                    data: $('#myform').serialize(),
                    timeout: 30000, // 30 seconds
                    cache: false,
                    beforeSend: function(html) { // this happens before actual call
                        $("#results").html(''); 
                   },
                    error: function(){
                        $("#result").hide().html('server not responding');
                    },
                    success: function(msg){ // this happens after we get results
                        $("#result").html(msg);
                    }
                });
            }

            else
            {
                return false;
            }
        }); 
    });  
    </script>
</head>
<body>

<form id="myform" method="post" action="save.php">
    <textarea class="text" name="message" id="message"></textarea>
    <input type="submit" name="submit" id="submit" value="submit" />
</form>

<!-- this is where Ajax will display the result -->
<div id="result"></div>

<!-- this is where old data will be displayed -->
<div id="messages">
    <?php

        if(mysql_num_rows($q) > 0)
        {
            while($r = mysql_fetch_assoc($q))
            {
                echo '<div class="block">
                    <p class="date">'.$r['creation_date'].'</p>
                    <p class="message">'.$r['message'].'</p>
                </div>';
            }
        }
    ?>

</div>
</body>
</html>

And this is the script which receives data from the form, i.e. save.php:

<?php

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

What do you mean with "push back"?

cereal 1,524 Nearly a Senior Poster Featured Poster

The French looked like a shadow of their former selves

same of Italy :(

cereal 1,524 Nearly a Senior Poster Featured Poster

Add CURLOPT_RETURNTRANSFER:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

And try simplexml_load_string here:

$xml = simplexml_load_file(utf8_encode($xml_url), 'SimpleXMLElement', LIBXML_NOCDATA);

bye!

mehnihma commented: Thanks, overlooked your post +2
cereal 1,524 Nearly a Senior Poster Featured Poster

@ska

check this: http://sourceforge.net/projects/php-proxy/

But if you set a proxy in your website to redirect youtube, you and the other users should also connect to it through a proxy or a VPN, so that authorities cannot trace your activity.

Read this as reference: http://en.rsf.org/fighting-cyber-censorship-12-09-2012,43366.html

cereal 1,524 Nearly a Senior Poster Featured Poster

Try to change quotes with backticks in the field names of the INSERT statement, as here:

$req = "INSERT INTO $tablename(`$tablecol`) VALUES ('$tablecoldat')";

Also, to catch an error use mysql_error() at least in this stage:

 mysql_query($req, $connection) or die(mysql_error());
cereal 1,524 Nearly a Senior Poster Featured Poster

Is it advantageous to instead do something like $this->cache = new Memcached(rand(1,10)); to create a connection pool of 10 different open connections?

Sincerly I don't know, I've searched a bit, but I didn't found anything neither in websites nor in books ;(

cereal 1,524 Nearly a Senior Poster Featured Poster

Try to add:

Memcached::OPT_TCP_NODELAY => true

It seems to work for me.

cereal 1,524 Nearly a Senior Poster Featured Poster

Change this:

<?PHP
$username = $_POST['username'];
print($username);
?>

to:

<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    $username = $_POST['username'];
    print($username);
}
?>

and it should work, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok then use mysql_error() the query fails, maybe because the variables are not set:

mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `recover_password` = '$recover_password'") or die(mysql_error());

A part from that consider to use mysql_num_rows() for this task, something like: mysql_num_rows($q) > 0 ? true : false;

cereal 1,524 Nearly a Senior Poster Featured Poster

Yup, add quotes to $recover_password:

mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `recover_password` = '$recover_password'")
cereal 1,524 Nearly a Senior Poster Featured Poster

A foreach loop will work:

foreach($ab as $k => $v)
{
    echo "$k  -  $v \n";
}

If you wan to group them in different arrays then use:

$keys = array();
$values = array();
foreach($ab as $k => $v)
{
    $keys[] = $k;
    $values[] = $v;
}

print_r($keys);
print_r($values);

Or better use array_keys() and array_values():

$ab = array('0'=>'10','1'=>'5','2'=>'8');
$ba = $ab;
asort($ba);

print_r(array_keys($ba));
print_r(array_values($ba));

Ok?

cereal 1,524 Nearly a Senior Poster Featured Poster

Also, if you want to resend passwords then create a new one automatically, or use AES_ENCRYPT / AES_DECRYPT in MySQL, change the password field to text or blob as in this example:

CREATE TABLE `users_test` (
`id` int(9) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` blob NOT NULL,
`password_hash` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8

And then try:

INSERT INTO users_test (username, password, password_hash) VALUES ('username',AES_ENCRYPT('my_password','hash'),sha1('my_password'));

If you go to perform a normal select you get:

select * from users_test;
+----+----------+------------------+------------------------------------------+
| id | username | password         | password_hash                            |
+----+----------+------------------+------------------------------------------+
|  1 | username | <F8><E9><?<F4>^L<8B>^Y<9A><84><8C>4\<8D><AA>^B          | 5eb942810a75ebc850972a89285d570d484c89c4 |
+----+----------+------------------+------------------------------------------+

But if you use AES_DECRYPT:

select id, username, AES_DECRYPT(password,'hash') as password, password_hash from users_test;

+----+----------+-------------+------------------------------------------+
| id | username | password    | password_hash                            |
+----+----------+-------------+------------------------------------------+
|  1 | username | my_password | 5eb942810a75ebc850972a89285d570d484c89c4 |
+----+----------+-------------+------------------------------------------+

You get the correct value. So, this is a safer solution than plain text:

https://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html#function_aes-encrypt

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

For that you need asort():

$ab = array('0'=>'10','1'=>'5','2'=>'8');
$ba = $ab;
asort($ba);
print_r($ba);

And you get:

Array
(
    [1] => 5
    [2] => 8
    [0] => 10
)

http://www.php.net/manual/en/function.asort.php
bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

@lixamaga it's not safe because a user can disable javascript and submit malicious data, a server side filter, as blocblue suggested, is a necessary requirement.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hmm, maybe I'm not understanding your question, can you please post your code and spot the problem?

cereal 1,524 Nearly a Senior Poster Featured Poster

This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.

source: http://php.net/manual/en/function.sort.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Welcome back! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Italian, then English, Spanish, French and I can understand a bit of German and Portuguese, both written. As soon as I can I would like to study Farsi, Russian and Hebrew.

cereal 1,524 Nearly a Senior Poster Featured Poster

The first problem is $xx which is a string:

var_dump($xx); # output: string(5) "$_GET"

if you want to assign _GET as variable name then use $$ as:

$xx = '$' . $value;
var_dump(${$xx}); # output: Notice: Undefined variable: $_GET

but as seen, this is not enough, so change it to:

var_dump(${$value});

and by running /test.php?a=hello&b=world you will get what expected:

array(2) { ["a"]=> string(5) "hello" ["b"]=> string(5) "world" }

so at the end write:

$xx = ${$value};

Read these as reference:
* http://php.net/manual/en/language.variables.variable.php
* http://www.php.net/manual/en/language.variables.variable.php#81033

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome, hope it was useful.. :D bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

You are missing the echo in the first group:

<label for="accommodationYes" class="accomm" id="accommY">
<input name="accommodation" type="radio" id="accommodationYes" style="display:none;" value="Yes"<?php echo set_radio('accommodation', 'Yes'); ?>>
<span class="custom radio"></span> Yes
</label>
<label for="accommodationNo" class="accomm" id="accomN">
    <input name="accommodation" type="radio" id="accommodationNo" style="display:none;" value="No"<?php echo set_radio('accommodation', 'No'); ?>>
    <span class="custom radio"></span> No
</label>

EDIT
You don't even imagine what I've done to find this.. I didn't think about echo until I checked all the mechanism.. LOL! I'm pasting my previous text just to let you see how much dumb I'm feeling now x_x :D

========================================================================

It seems a bug but I don't understand why, I made a test and I got your same results, here's my code.

The Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends CI_Controller
{

    public function start()
    {
        $this->load->helper(array('form', 'url'));
        if(validation_errors())
        {
            $error_object =& _get_validation_object();
            $d['errors'] = $error_object;
        }
        else
        {
            $d['errors'] = false;
        }
        $this->load->view('test/start',$d);
    }

    public function form()
    {
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');

        $this->form_validation->set_rules('name', 'Name', 'required|xss_clean');
        $this->form_validation->set_rules('accommodation', 'Accommodation', 'required|xss_clean' );     
        $this->form_validation->set_rules('payment', 'Payment', 'required|xss_clean' ); 
        $this->form_validation->set_error_delimiters('<li>', '</li>');

        if($this->form_validation->run() === FALSE)
        {
            $this->start();
        }
    }
}
The View
<!DOCTYPE html>
<html>
<head></head>
<body>
<?php

    echo form_open('/test/form');
?>
<label for="name">Name <input type="text" name="name" /></label>
<label for="accommodationYes" class="accomm" id="accommY">
    <input name="accommodation" type="radio" id="accommodationYes" value="Yes"<?php set_radio('accommodation', 'Yes'); ?>>
    <span class="custom radio"></span> Yes
</label>
<label for="accommodationNo" class="accomm" id="accomN">
    <input name="accommodation" type="radio" id="accommodationNo" value="No"<?php set_radio('accommodation', 'No'); ?>>
    <span class="custom radio"></span> No
</label>
 <label for="eft"><input name="payment" type="radio" id="eft" value="EFT"<?php echo set_radio('payment', 'EFT'); ?>><span class="custom radio"></span> EFT</label>
 <label for="cash"><input name="payment" type="radio" …
cereal 1,524 Nearly a Senior Poster Featured Poster

Yup, it's pretty simple:

<?php
    function gravatar($email,$size = 75)
    {
        $avatar = md5(strtolower(trim($email)));
        return '<img class="avatar" src="http://www.gravatar.com/avatar/' .$avatar.'.jpg?d=identicon&s='.$size.'" alt="avatar" />';
    }

    echo gravatar('random@mail.tld');
?>

It returns an image even if there's no registration there.

cereal 1,524 Nearly a Senior Poster Featured Poster

You should get the file list inside the directory to delete, loop ftp_delete() for each and ftp_rmdir() for each subdirectory, but they need to be empty as the main directory to delete. So it's a bit tricky, the functions you need to use are:

ftp_delete()
ftp_nlist()
ftp_rmdir()

http://php.net/manual/en/ref.ftp.php

You can also use functions like opendir(), unlink() and rmdir():

unlink('ftp://user:password@ftp_server');

but in the case of rmdir and ftp_rmdir the directory needs to be always empty and you need permissions, so in some occasions you'll need to use chmod() or ftp_chmod() since the ftp user is different from the server user, usually www-data.

In Addition
If you have to do a lot of this activity it could be better to place a script in the remote server, use cron to make it wait instructions and from local send a simple file or $_POST with the name of the directory to delete, you can use ftp_* or even curl. Just make sure that these ftp accounts are jailed otherwise it becomes dangerous.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use GeoIP library, for example:

$countrycode = geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
$loc = '/default/contents';
switch($countrycode)
{
    case 'FR':
        $loc = '/fr/contents';
    break;
    case 'IT':
        $loc = '/it/contents';
    break;
    case 'US':
        $loc = '/us/contents';
    break;
}

header('Location: '.$loc);

at that point you can also place a cookie to switch automatically each time the user comes back, but in order to use it you have to install the library:

This can be done with PECL or by command line, in debian/ubuntu type:

sudo apt-get install php5-geoip

Note, some of the functions as geoip_region_* will not work if you don't load the correct database, some of them are only available by payment, by default you get the Country database both IPV4 and IPV6, there is also the City db available for free:

In case you want to use it: download it, use gunzip to decompress the file gunzip GeoLiteCity.dat.gz and place it inside /usr/share/GeoIP/

EDIT
As side note, this can work also with other free GeoIP databases, but I didn't tested.

Hope is useful, bye.

blocblue commented: Very helpful resource +9
cereal 1,524 Nearly a Senior Poster Featured Poster

Also, since you are querying a specific mID and then grouping by the same field, it's correct to get just a row. So try to change the GROUP BY clause. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

if you are not referring to remote identification then try php_uname(): http://php.net/manual/en/function.php-uname.php

echo php_uname();

there is also posix_uname() which returns the same information into an array format, but I'm not sure if it works on Windows without one of these: http://en.wikipedia.org/wiki/POSIX#POSIX_for_Windows

print_r(posix_uname());

but in any case, as LastMitch wrote, this will not give a specific values about the machine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Try:

$andy->load_Array(array("andy","bill"));

right now you are sending two arguments, otherwise use func_get_args(): http://php.net/manual/en/function.func-get-args.php

Also instead of var $element use private|protected|public:

public $element;

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition from manual: http://dev.mysql.com/doc/refman/5.0/en/load-data.html

Windows path names are specified using forward slashes rather than backslashes. If you do use backslashes, you must double them.

The explain command instead, it is used to display the table structure: http://dev.mysql.com/doc/refman/5.0/en/explain.html

cereal 1,524 Nearly a Senior Poster Featured Poster

can you post the output of explain stock_names?

cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried to use mysqladmin?

mysqladmin -uroot password your_password -h localhost

If you are using Windows browse to the directory which contains the tool and add the extension .exe to mysqladmin command, it should be something like cd \Program Files\MySQL\MySQL server5.0\bin and then:

mysqladmin.exe -uroot password your_password -h localhost

With this command you set the root password and then, finally, you can log into the database server:

mysql -uroot -pyour_password

More info:

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Here there's the example of PHP manual: http://php.net/manual/en/curl.examples-basic.php

<?php

$ch = curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

but you can do the same with file_get_contents() and file_put_contents():

$url = 'http://www.example.com/';
$page = file_get_contents($page);
file_put_contents('example_homepage.txt',$page);
cereal 1,524 Nearly a Senior Poster Featured Poster

It's a bit old but you can download it from here: http://mirrors.fedoraproject.org/publiclist/Fedora/9/

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use cryptsetup: http://code.google.com/p/cryptsetup/
Here there is a tutorial for external drives:

https://help.ubuntu.com/community/EncryptedFilesystemsOnRemovableStorage

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

In practice you need a web crawler and from that the ability to search contents, there are some ready solutions for these tasks, you can check for Sphider: http://www.sphider.eu/docs.php#commandline

Or read here: http://www.daniweb.com/web-development/php/threads/365235/create-a-php-spider

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Works fine for me, maybe it's the $dir variable? As suggestion use print_r() on line 11, just before the while loop, to check the $files array:

print_r($files);
cereal 1,524 Nearly a Senior Poster Featured Poster

Probably you get an empty set from this query:

SELECT * FROM PO ORDER BY PO ASC

Try it from a mysql client.

cereal 1,524 Nearly a Senior Poster Featured Poster

You are missing the $ sign in front of the variable name, change it to $username, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

I still didn't tested Laravel but it seems interesting. While searching I've found this blogpost which is enough explanatory, at least in comparison to CI:

http://philsturgeon.co.uk/blog/2012/12/5-things-codeigniter-cannot-do-without-a-rewrite

A good point is the support for composer packages: http://getcomposer.org/

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

First this is wrong:

if ($sql = $s){

here you are assignin a value, not comparing, to compare use == or for boolean ===, so rewrite it to:

if ($sql == $s){

Second, I don't see $sql declared anywhere, you will get an error here.
Third, you have to extract the filename from the query:

if(mysql_num_rows($t) > 0)
{
    # loop results
    while($row = mysql_fetch_object($t))
    {
        unlink('/path/'.$row->filename); # and extension if this is saved a part
    }
    header('Location: lee_remove.php');
}

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Same problem here. By the way, I don't know if this was already the behave: it seems Business Exchange requires log in.

cereal 1,524 Nearly a Senior Poster Featured Poster

If you can, change the DocumentRoot in the Apache httpd.conf file or inside the virtual host configuration file:

DocumentRoot /var/www/website/abc

http://httpd.apache.org/docs/2.2/urlmapping.html#documentroot

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

As already suggested elsewhere change:

$db['default']['hostname'] = "//localhost/";

to:

$db['default']['hostname'] = "localhost";

bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

This kind of libraries usually are very strict, so if there's something wrong in your HTML then it will break with an error like yours. It will be more useful if you paste here the code of your page.

In addition, as suggestion, get the HTML output and try to validate it:

http://validator.w3.org/

bye!