cereal 1,524 Nearly a Senior Poster Featured Poster

Just to answer to the question, the getAll() method will return a multidimensional array so, if you want to print the results, you have to loop it as an associative array:

foreach($rows as $author)
{
        echo $author['first_name'];
}

When you apply the convertToBeans() method you get an array of objects:

foreach($authors as $author)
{
        echo $author->first_name;
}

Here you can see the source of the file that defines the method, i.e. OODB.php:

In your example you can spot the difference by using print_r over the variables $rows and authors. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

I tried the tutorial, works fine for me. Regarding your code:

<?php echo form_open('verifylogin'); ?>

Should be:

<?php echo form_open('admin/verifylogin'); ?>

Then into controllers/admin/verifylogin.php you have to change the redirect from home to /admin/home, so at line 27:

redirect('/admin/home', 'refresh');

the same applies to the other controllers redirects as example in /admin/home.php.

After the login I get this error:

Unable to load the requested file: admin/admin.php

Which is the view file: standing at the example it should be home_view.php, so this error is probably limited to my test and fixing this it works all fine.

Just remove the session_start() at the beginning of controllers/admin/home.php because you don't need it, since here we are using the CI session library. And you can remove all the PHP closing tags at the end of the controllers, if you want to use it, then be sure to remove all the spaces after that tag, otherwise you can get errors, ref.: http://ellislab.com/codeigniter%20/user-guide/general/styleguide.html#php_closing_tag

Going back to you, can you show your .htaccess contents?

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition, check the documentation: http://dev.mysql.com/doc/refman/5.6/en/mysql-indexes.html

Especially:

Indexes are less important for queries on small tables, or big tables where report queries process most or all of the rows. When a query needs to access most of the rows, reading sequentially is faster than working through an index. Sequential reads minimize disk seeks, even if not all the rows are needed for the query.

Anyway it's the query optimizer that will decide if the query will use the available indexes or not, you can force it to use a specific index or to ignore them all, read these links for more information:

So, at end, test your queries, use the explain select ... and see when you get better results.

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, I do not see anything wrong. Maybe mod_rewrite is not enabled? You can check by running:

apache2ctl -M

Or in case of a Windows box:

httpd -M

Or simply remove the IfModule statements and see if it generates an error.

cereal 1,524 Nearly a Senior Poster Featured Poster

No problem. Are you sure .htaccess is not read? Can you show his contents? Do you get any message in the error.log file?

There could be a misconfiguration, for example with the actual setting if there is an Options call, the .htaccess will generate an error.

Most of the times you can place in the config file the same code that you would write into an .htaccess file, it will execute faster. So if in your old installation there were other settings, then this can explain the errors you get now. Right now the easiest test you can perform is to change AllowOverride to All and reload Apache.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, are you using this sdk? https://github.com/facebook/facebook-php-sdk

Do you get any errors?

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok :)

To reply to your question: the problem of those lines of code is that the script is submitting the same array to both instances of setBcc() with different names. But the values are exactly the same. For this same reason, at the moment, you do not notice any problem.

If you change one of the instances of setBcc() to use another array, then you will notice that something is not working well, because it will be considered only the last one in the sequence. As I've already quoted from the documentation:

Multiple calls to setBcc() will not add new recipients -- each call overrides the previous calls. If you want to iteratively add Bcc: recipients, use the addBcc() method.

Ref: http://swiftmailer.org/docs/messages.html#setting-bcc-recipients

The $toArr is generated by explode() and this is an indexed array, not an associative, so the array_values() can be avoided, as example:

$a = array('q','w','e','r','t','y');
print_r($a);

# will print:
Array
(
    [0] => q
    [1] => w
    [2] => e
    [3] => r
    [4] => t
    [5] => y
)

By applying the array_values() to the above array, you will get the same output: print_r(array_values($a));. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

This does not make sense:

$to = $_POST['emaile'];
$toArr = array();
$toArr = explode ( ',', $to );
$pulapka = array_values($toArr);
$message->setBcc($toArr);
$message->setBcc($pulapka);

Because only the last setBCC() is considered by SwiftMail, the others are discarded. Also you can rewrite it this way:

$to = array_map('trim', explode(',', $_POST['emaile']));
$message->setBcc($to);

Otherwise you have to loop each one with the addBCC() method:

foreach($to as $email)
{
    $message->addBCC($email);
}

If you have 2 different source from which you get the recipients, and both are strings, then you have to generate the arrays and merge them:

$toArr = array_unique(array_merge($to, $pulapka));

So the $pulapka array must be prepared as the $to:

$pulapka = array_map('trim', explode(',', $_POST['pulapka']));

The above would become:

$to = array_map('trim', explode(',', $_POST['emaile']));
$pulapka = array_map('trim', explode(',', $_POST['pulapka']));

$toArr = array_unique(array_merge($to, $pulapka));
$message->setBcc($toArr);

Regarding FROM if you want to include a name, as Allegro.pl, then you must use an associative array, i.e. key => value:

$message->setFrom(array('no-reply@admin.allegro.pl' => 'Allegro.pl'));

And it should work all fine.

cereal 1,524 Nearly a Senior Poster Featured Poster

Standing at your last code this error should not happen, unless you're feeding Allegro.pl through $pulapka array. You may want to merge the arrays? To add single emails, use addBCC(), from the documentation:

Multiple calls to setBcc() will not add new recipients -- each call overrides the previous calls. If you want to iteratively add Bcc: recipients, use the addBcc() method.

Can you show the form?

cereal 1,524 Nearly a Senior Poster Featured Poster

These are the links to the documentation for explode and for print_r:

The last one is used to check the contents of an array:

print_r($toArr);

Use it only to debug your application. Since there are spaces run also my second suggestion, the trim function which will remove the spaces at the beginning and at the end of a string:

The function array_map is used to loop the elements of an array and apply a function, in this case trim, to each of them, since this is not a multidimensional array it should work fine:

This:

$pulapka = -> setBcc($toArr);

is not correct, change it to:

$message->setBcc($toArr);

If you still have problems, show the updated code.

EDIT

I see you have written a lot, in the meaning time, line 45 is still wrong:

$message->setFrom("no-reply@admin.allegro.pl", "Allegro.pl");

Convert it to an array, otherwise you have to remove the second parameter:

$message->setFrom(array("no-reply@admin.allegro.pl" => "Allegro.pl"));

At line 6 change the variable to $message:

$message = Swift_Message::newInstance();

Ref: http://swiftmailer.org/docs/messages.html

cereal 1,524 Nearly a Senior Poster Featured Poster

One of the emails is not a valid, but I think this is related to your example here. At line 16 you must use an array to set the name of the sender:

$message->setFrom(array('email@here.tld', 'Name'));

I do not understand this part:

Of course I paste email in the textbox with all necessary letters like inside the array.

Can you explain better? Can you show how you're trying to catch the emails from the textbox? If you separate them by a comma you can use the explode() function, an example:

$mails = explode(',', $_POST['emails']);
$mails = array_map('trim', $mails); # to remove extra spaces
cereal 1,524 Nearly a Senior Poster Featured Poster

Check out for Sequel Pro or MySQL Workbench:

Or you can always use the command line client.

Note: if, from Firefox, you were using PHPMyAdmin to connect to a remote database, make sure you can directly connect to it from your IP, sometimes remote connections are not allowed or are restricted to specific addresses. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

Add 1 after FORWARD, that will put the rule in the first place of the chain, otherwise the firewall applies the first matching rule.

The number given after the chain name indicates the position before an existing Rule. So, for example, if you want to insert a Rule before the third rule you specify the number 3. Afterward, the existing Rule will then be in the fourth position in the chain.

More information: https://fedoraproject.org/wiki/How_to_edit_iptables_rules

cereal 1,524 Nearly a Senior Poster Featured Poster

The die (aka exit) construct requires parenthesis when you send a status, so this is wrong:

die 'error here';

The correct version is:

die('error here');

Reference: http://php.net/manual/en/function.exit.php

cereal 1,524 Nearly a Senior Poster Featured Poster

Happy Birthday! :D

cereal 1,524 Nearly a Senior Poster Featured Poster

I get that you are doing that because they would validate, but wouldnt this require that it compares each record by hashing (and reading, anyway) it in order to compare?

Yes, that's the reason why I'm also suggesting to use a unique index over the title column: the insert query will return the SQL state and the user will know that the title is already in use:

$q = $conn->exec('insert into table (title) values("hello world")');
if($conn->errorCode() == 23000) echo 'this title already exists';

More can be done: as removing the punctuation and creating the url slug of the title and use that to create the unique key:

# on mysql client
> alter table tablename add url_slug varchar(255) not null unique;

# on php script
$q = $conn->exec('insert into table (title, url_slug) values("hello world", "hello_world")');
if($conn->errorCode() == 23000) echo 'this title already exists';

Then it depends on the applications features, if you have to deal with big numbers and the slug is not requested, it can be used an hash which has always a fixed length and can be saved as binary:

# on mysql client
> alter table tablename hash binary(16) not null unique;

# on php script
$hash = md5($url_slug);
"insert into table (title, hash) values('$title', unhex('$url_slug'))"

And it should be more efficient than a table scan.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use an the md5() MySQL function and do everything within the query:

"select id from table where md5(title) = md5({$newtitle}) limit 1"

Then just check with mysql_num_rows() > 0. Or better: create a unique index for the title column.

cereal 1,524 Nearly a Senior Poster Featured Poster

At line 19 close the tag </Directory>. Then reload Apache and it should work. Also consider to enable the ServerName at line 9.

cereal 1,524 Nearly a Senior Poster Featured Poster

Since I don't have a windows box, unfortunately I cannot test and I'm realizing that runas never accepts pipes or redirections (with the pro edition, maybe, you could use the /savecred option), so excuse me for the wrong suggestion.

If the user that you have to call through runas is static, then you could change the apache user to the same one, or at least to the same group, so it should execute the script with the correct privileges. At that point you should be able to avoid runas.

Anyway, while waiting for more appropriate support from windows people, I can only think to try to serve the script as a windows service, so outside from an Apache instance, and use another script to send the input. Good luck!

cereal 1,524 Nearly a Senior Poster Featured Poster

Try with a pipe:

exec('echo "password" | runas /user:<Computer>\User "notepad.exe"');

Reference: http://technet.microsoft.com/en-us/library/bb490982(en-us).aspx

cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, checking the source (at line ~2804 of sql/item_sum.cc in MySQL 5.5) now I understand:

/*****************************************************************************
GROUP_CONCAT function

SQL SYNTAX:
GROUP_CONCAT([DISTINCT] expr,... [ORDER BY col [ASC|DESC],...]
[SEPARATOR str_const])

concat of values from "group by" operation

BUGS
Blobs doesn't work with DISTINCT or ORDER BY
*****************************************************************************/

The group by is mandatory when using group_concat() because the latter is a function of the former. Looking at the manual with fresh eyes, I realize, it was pretty obvious. (Point and laugh!) 5020680b456e96307aa312265db3c372

In fact I start to get the empty results sets as expected, however I still don't get the Impossible WHERE..., but this is unrelated. I leave an example for the log:

select f.name, group_concat(quality) quality, sum(fs.quantity) quantity, sum(fp.price*fs.quantity) price from (select * from fruits where name = 'apple') as f, fruitstock as fs, fruitprices as fp where f.id = fs.fruit_id and f.id = fp.fruit_id and f.id in(4) group by name;
Empty set (0.00 sec)

Live example: http://sqlfiddle.com/#!2/53ed8f/7

Ref: http://dev.mysql.com/doc/refman/5.6/en/group-by-functions.html#function_group-concat

Thanks for your time! ;D

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,

so I was trying few relations between tables and I noted an unexpected behaviour when using group_concat(). Let say I have three tables: fruits, fruitstock and fruitprices. These are the structures:

create table fruits (
    id tinyint unsigned not null auto_increment primary key,
    name varchar(50) not null,
    quality varchar(50) not null
    ) engine = myisam default charset = utf8;

create table fruitstock (
    id tinyint unsigned auto_increment primary key not null,
    fruit_id tinyint unsigned not null,
    quantity tinyint unsigned not null default 0
    ) engine = myisam default charset = utf8;

create table fruitprices (
    id tinyint unsigned not null auto_increment primary key,
    fruit_id tinyint unsigned not null,
    price int unsigned not null default 0
    ) engine = myisam default charset = utf8;

And this is the data used to populate the tables:

insert into fruits (name, quality) values('apple', 'granny smith'), ('apple', 'fuji'), ('apple', 'red delicious'), ('apple', 'pink lady'), ('apple', 'jonagold'), ('apricot', 'sungiant'), ('avocado', 'hass'), ('avocado', 'gem'), ('cherry', 'autumnalis'), ('cherry', 'kanzan'), ('cheery', 'pandora');

insert into fruitstock (fruit_id, quantity) values(1, 10), (2, 23), (3, 7), (4, 100), (5, 50), (6, 0), (7, 20), (8, 1), (9, 15), (10, 21);

insert into fruitprices (fruit_id, price) values(1, 100), (2, 98), (3, 110), (5, 20), (8, 120), (10, 140), (11, 200);

Where fruit_id is used as foreing key in the last two tables. Now if I try a query to show the price of the apples in stock I run:

select f.name, group_concat(quality) quality, sum(fs.quantity) quantity, sum(fp.price*fs.quantity) price …
cereal 1,524 Nearly a Senior Poster Featured Poster

Use the t option to limit the transcoding:

ffmpeg -t 15 -i file.wav -f mp3 file.mp3

For more information type man ffmpeg or read this link (it's the same manual):

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe you can add the base64 option to the openssl command, unfortunately I cannot try right now but follow this:

otherwise you can use base64 command from the command line:

base64 --decode source.txt > Abc.xml

But in this last case, as with base64_decode() in PHP, you have to remove the headers.

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

Have you tried to change the type, in the ajax call, to DELETE?

cereal 1,524 Nearly a Senior Poster Featured Poster

Yes, when you get heavy traffic it can slow down responses, but you have few options: http://htmlpurifier.org/docs/enduser-slow.html

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Consider to use HTML Purifier in your application: http://htmlpurifier.org/

It will give you the ability to whitelist the tags that you want to allow and, most important, it will validate the attributes, removing the javascript included.

cereal 1,524 Nearly a Senior Poster Featured Poster

@cussel try this:

<?php

$data = array(
    array("1" => "12306"),
    array("0" => "12106"),
    array("1" => "12770"),
    array("3" => "12770"),
    array("3" => "12306"),
    array("3" => "12770")
);

$newdata = array();
$result = array();
$i  = 0;


# reduce and reverse the $data array
foreach($data as $key => $value)
{
    $newdata[][current($value)] = key($value);
}

# compare $data with $values
foreach($data as $key => $value)
{
    $matches    = array();
    $currentkey     = key($value);
    $currentvalue   = current($value);

    foreach($newdata as $newkey => $newvalue)
    {
        $thiskey    = key($newvalue);
        $thisvalue  = current($newvalue);

        if(in_array($thiskey, $value) && $thiskey == $currentvalue) $matches[$thisvalue] = $thiskey;
    }

    # get max key from matches
    $maxkey = max(array_keys($matches));

    if($currentkey == $maxkey) $result[$i][$maxkey] = $matches[$maxkey];
    $i++;
}

print_r($result);

It will output your same expected result. Here there is an extended version, a bit messy but which gives a clue of what is going on: http://pastebin.com/1D3ruVya

The output of the pasted link is:

For key #1 in $data[0] with value 12306

KEY VALUE1  VALUE2  COMPARE
#1   12306   12306  =
#0   12106   n/f
#1   12770   n/f
#3   12770   n/f
#3   12306   12306  +
#3   12770   n/f
            Matches: 2 {"1":12306,"3":12306}
            Discarded
--------------------------------------------------------

For key #0 in $data[1] with value 12106

KEY VALUE1  VALUE2  COMPARE
#1   12306   n/f
#0   12106   12106  =
#1   12770   n/f
#3   12770   n/f
#3   12306   n/f
#3   12770   n/f
            Match: 1 {"0":12106}
            Chosen key: #0
--------------------------------------------------------

For key #1 in $data[2] with value 12770

KEY VALUE1  VALUE2  COMPARE
#1   12306   n/f
#0   12106   n/f
#1   12770   12770  =
#3   12770   12770  + …
cereal 1,524 Nearly a Senior Poster Featured Poster

@AD right now you can try with:

member "dani" site:daniweb.com

On the google search bar seems to work. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, this is not enough, at least for me, to solve the problem:

  • Is the Asset_ID a foreing key that points to another table or this is an auto increment key?
  • If there is another table involved, can you provide all the schemas?
  • Is Asset_ID unique in the asset_update table?
  • Is this table temporary or are you using an engine different from myisam?
  • When and how the Depreciation_Start_Date and the Disposal_Date are inserted and selected?

Your insert queries do not consider the date colums, and your last query does not consider the Disposal_Date. I'm asking for the structure of the tables from my first post in this thread, a list of the column names does not help me, so:

show create table asset_update;

And any other table involved. If the date colums, for example, are stored into a foreing table assets, then you can use the asset_update to generate the monthly depreciations, basing:

  • on the given range date set in the assets table,
  • or on the current month

Currently it seems these dates needs to be inserted sooner or later, but it's not clear how: as update, as insert?

Anyway, if you're using a schema with two or more tables, please provide as much information as possible. Otherwise me or any other user will continue to suggest wrong solutions. I've started trying with a schema as I'm supposing above, but at the moment I'm really busy, so I cannot test. In fact, excuse me if I'm …

cereal 1,524 Nearly a Senior Poster Featured Poster

Sorry for my late reply,

the problem with your above query is that it will return multiple rows, in general if you want to get results through the variables of a procedure, then you can return only single rows. Your query returns these kind of results: http://sqlfiddle.com/#!2/44386/1 But I do not understand how you want to apply that.

I need to see the table structure, right now I'm going blindly, so I need the output of this command:

show create table asset_update;

In your first code there was no Date_Acquired column, so I didn't considered this in the insert of values and I do not know how this is set. Can you provide a sample data?

From what I understand you want to set a range limit basing on the Estimated_Useful_Life or/and on the Date_Acquired column, correct? What it should happen when the data inserted is out of range? It is not considered?

At the moment the procedure gets the monthly depreciation of the previous row and adds it to the current, and that's all; you want to use some IF statements to fill or not some columns? In practice, try to explain what you want to achieve with the above query, that way me or someone else will be able to help. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Aside note: when you go to an internet cafe here in Italy, bring an ID document with you: the operator has to register each user, this is requested by our legislation. For this reason, you cannot use your own laptop, nor your usb distribution: because in these cases the user has the power to fake the mac address, can scan the lan... and can make it difficult to identify the author of an illegal action.

There are exceptions: if you use the free wifi access point of a business, whose primary activity is not the provision of internet access (as a restaurant, an airport, a train), then the admins are not obliged to request your documents. But in this case you need a laptop.

Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

So if $camp['pozitie'] has a specific value and $camp['cod_garantie'] is empty, you have to alter all the following positions, correct?

You can add a counter and add it to the position key, here's an example:

<?php

$datum[] = array('name' => 'sun', 'pos' => 1, 'magnitude' => '-26.74');
$datum[] = array('name' => 'venus', 'pos' => 2, 'magnitude' => '-5');
$datum[] = array('name' => 'sedna', 'pos' => 3, 'magnitude' => '');
$datum[] = array('name' => 'neptune', 'pos' => 4, 'magnitude' => '8');
$datum[] = array('name' => 'io', 'pos' => 5, 'magnitude' => '');
$datum[] = array('name' => 'moon', 'pos' => 6, 'magnitude' => '-12.74');

echo PHP_EOL;

$i = 0;

foreach($datum as $key => $value)
{
        if(empty($value['magnitude']))
        {
                $i++;
        }

        if($i > 0) $value['pos'] = $value['pos'] + $i;

        echo "\t" . $value['pos'] . ' ' . $value['name'] ."\t" . $value['magnitude'] . PHP_EOL;
}

echo PHP_EOL;

will output:

1 sun       -26.74
2 venus     -5
4 sedna 
5 neptune   8
7 io    
8 moon      -12.74

Note rows 4 and 7, the original values are 3 and 5.

cereal 1,524 Nearly a Senior Poster Featured Poster

*Notice: Access denied for user ''@'localhost' to database 'mag_rocket

As JorgeM said, the error means that the user you're providing does not own privileges to the database you're trying to connect. User and password are correct, but the admin has to change the permissions settings for your username. Open a mysql shell with the mysql admin account and use:

GRANT ALL PRIVILEGES ON mag_rocket.* TO 'username_here'@'localhost';

Check this for more information:

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

Without seeing the complete code it's difficult to suggest the correct solution. It can be related to Dani's suggestion, so:

Or your hosting plan does not have the buffering enabled. If you're in doubt first try to open the script with different browsers, otherwise try with a cURL request to see if you get something. In some cases the browsers do not output because there is not enough data in their buffers.

If you're still in doubt and you cannot check the error and access log files, then you may want to ask to the GoDaddy Support Team.

cereal 1,524 Nearly a Senior Poster Featured Poster

Sorry my fault, change $id = ''; to $id = array(); and it should work:

$id = array();
if(array_key_exists('id', $_GET))
{
    $id = explode('/',$_GET['id']);
}
$_GET['id'] = array_key_exists(0, $id) ? $id[0] : 'twitter';
$_GET['p'] = array_key_exists(1, $id) ? $id[1] : ''; # set default here
cereal 1,524 Nearly a Senior Poster Featured Poster

Sorry I was actually referring to the second die function, try:

<?php

$mysql_hostname = "localhost";
$mysql_user = "";
$mysql_password = "";
$mysql_database = "mag_rocket";
$prefix = "";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die(mysql_error());
mysql_select_db($mysql_database, $bd) or die(mysql_error());

By the way, the connect string was lacking of second and third parameters, i.e. username and password.

cereal 1,524 Nearly a Senior Poster Featured Poster

These error are the same of the previous? Can you post the complete script and the exact errors?

cereal 1,524 Nearly a Senior Poster Featured Poster

It seems that $_GET['id'] on line 5 expects the value as id=bar/foo, then this is rewritten by splitting the string to id and p keys on line 7 and 8.

@Donima4u you can replace this:

$id = explode('/',$_GET['id']);
$_GET['id'] = $id[0];
$_GET['p'] = $id[1];
if(empty($_GET['id'])) $_GET['id']='twitter';

With this:

$id = '';

if(array_key_exists('id', $_GET))
{
    $id = explode('/',$_GET['id']);
}

$_GET['id'] = array_key_exists(0, $id) ? $id[0] : 'twitter';
$_GET['p'] = array_key_exists(1, $id) ? $id[1] : ''; # set default here

Just be sure to set a default value for the p key. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

If you change die("Could not connect database"); with:

 die(mysql_error());

You should get the error code, if this does not help then paste the error here.

cereal 1,524 Nearly a Senior Poster Featured Poster

What kind of error do you get? Have you verified the error and access log files of your web server? From these files you can check the generated error codes.

This is working for me:

RewriteEngine On
RewriteRule ^(css|images|js|fonts) - [L]
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)$ index.php?id=$1&page=$2 [L]

If you try to access directly to the CSS file what header responses and contents do you get? If it is not configured properly, the server will try to return the index page contents instead of the CSS file. Usually the browser will return a blank page or will not reload. So you can try to debug by using:

curl http://localhost/css/file.css

If you don't have access to a cURL client, then you can use POSTMan, an extension for Google Chrome:

Once installed just open the tab and paste the URL of the CSS file, perform a GET request and see what you get.

Another possible solution is to place an .htaccess file inside the CSS directory, in this file you have to disable the rewrite engine:

RewriteEngine Off

Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you explain better? Are you referring to the css directory? You can disable the rewrite for some directories by adding this rule above yours:

RewriteRule ^(css|images|js|fonts) - [L]

If this does not solves then paste the entire rewrite rule and explain the issue, bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

I'm not sure if you're using a backtick at the end of the command to wrap \r\n, you have to use single quotes instead, so the correct command should be:

LOAD DATA LOCAL INFILE 'C:\\temp\\test.csv' INTO TABLE bd_george.test FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n' (id,name);

Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

An auto increment column MUST be integer, so you cannot use cc123, but you can create composite indexes, so you can create unique content, for example:

create table mytest(
    id int unsigned auto_increment,
    code varchar(3) not null,
    message text,
    primary key (code, id)
) engine = myisam default charset=utf8;

insert into mytest(code, message) values('aaa', 'hello'), ('bb', 'hi'), ('cc','hey'), ('aaa', 'world');
select * from mytest;

Will output:

+----+------+---------+
| id | code | message |
+----+------+---------+
|  1 | aaa  | hello   |
|  1 | bb   | hi      |
|  1 | cc   | hey     |
|  2 | aaa  | world   |
+----+------+---------+

Note that the id does not increments because the primary key is composed by the code and the id column in this order, in practice it is like using a unique index. If you reverse the index order:

primary key (id, code)

Then you get:

+----+------+---------+
| id | code | message |
+----+------+---------+
|  1 | aaa  | hello   |
|  2 | bb   | hi      |
|  3 | cc   | hey     |
|  4 | aaa  | world   |
+----+------+---------+
4 rows in set (0.00 sec)

As you see in this case there are consecutives increments on the id. More information:

You can also consider uuid_short() which return unique numeric strings:

An example of usage:

create table mytable_us(
    id bigint unsigned not null, …
cereal 1,524 Nearly a Senior Poster Featured Poster

Can you explain me more? You want to add it to the procedure or you want to use as separate query to analyze the rows?

Note: my previous example is fine for inserts, but it is not good for updates queries because it should loop every following row with the new values. I'm not sure how to deal with that. Probably the update trigger needs a separate procedure, or the accumulated depreciations should be calculated on the fly with a query, saving for example everything in a temporary table.

cereal 1,524 Nearly a Senior Poster Featured Poster

Solved:

create procedure process_asset_update (in Cost_Of_Acquisition double, in Estimated_Useful_Life double, inout Monthly_Depreciation double, inout Estimated_Residual_Value double, inout Accumulated_Depreciation double, in Asset_ID integer)
BEGIN
    declare result double(10,2) default '0.00';
    select au.Accumulated_Depreciation into result from asset_update as au order by au.Asset_ID desc limit 1;
    set Monthly_Depreciation = (Cost_Of_Acquisition / Estimated_Useful_Life)/12;
    set Estimated_Residual_Value = 10 * (Cost_Of_Acquisition);
    if result is null then set Accumulated_Depreciation = Monthly_Depreciation;
    else set Accumulated_Depreciation = Monthly_Depreciation + result;
    end if;
END|

It was the order by statement of the select query, it was referring to Asset_ID variable of the procedure not to the field name of the table, just change it to au.Asset_ID. Now it outputs:

+----+------+------+-------+--------+
| ID | CoA  | EUL  | MD    | AD     |
+----+------+------+-------+--------+
|  1 | 2500 |    5 | 41.67 |  41.67 |
|  2 | 2000 |    4 | 41.67 |  83.33 |
|  3 | 3000 |    6 | 41.67 | 125.00 |
|  4 | 1500 |    3 | 41.67 | 166.67 |
|  5 | 5000 |    9 | 46.30 | 212.96 |
+----+------+------+-------+--------+
5 rows in set (0.00 sec)

Live example: http://sqlfiddle.com/#!2/af493/1/0
Full code is attached.

As reference, the issue in my previous code is due to a naming conflict:

In addition, since float and double numbers are not accurate you should switch to decimal, read this for more information:

Bye!

mmcdonald commented: Nice work! OP Should add rep too 100% imo, Michael +4
cereal 1,524 Nearly a Senior Poster Featured Poster

example:monthly depreciation is 40 and accumulated value is 0 the result for accumulated value should be 40 when the value for monthly depreciation is 60 the accumulated value should add 40+60=100.

So when the new monthly depreciation is 20 the new accumulated depreciation becomes 120 because the previous accumulated value was 100? Am I correct?

Can you show the structure of the table? I've done few tests but I would like to understand more the structure to use, maybe I'm missing something. At the moment this is what I'm using:

CREATE TABLE `asset_update` (
  `Asset_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Cost_Of_Acquisition` double(4,0) DEFAULT NULL,
  `Estimated_Useful_Life` double(1,0) DEFAULT NULL,
  `Monthly_Depreciation` double(10,2) DEFAULT NULL,
  `Estimated_Residual_Value` double(10,2) DEFAULT NULL,
  `Accumulated_Depreciation` double(20,2) DEFAULT NULL,
  PRIMARY KEY (`Asset_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

And this is the procedure:

create procedure process_asset_update (in Cost_Of_Acquisition double, in Estimated_Useful_Life double, inout Monthly_Depreciation double, inout Estimated_Residual_Value double, inout Accumulated_Depreciation double, in Asset_ID integer)
BEGIN
    declare result double(10,2) default '0.00';
    select au.Accumulated_Depreciation into result from asset_update as au order by Asset_ID desc limit 1;
    set Monthly_Depreciation = (Cost_Of_Acquisition / Estimated_Useful_Life)/12;
    set Estimated_Residual_Value = 10 * (Cost_Of_Acquisition);
    if result is null then set Accumulated_Depreciation = Monthly_Depreciation;
    else set Accumulated_Depreciation = Monthly_Depreciation + result;
    end if;
END|

Right now it does not work correctly because it just sums the previous Monthly_Depreciation instead of the Accumulated_Depreciation, I'm probably doing something terribly wrong, but at the moment I really don't understand what, could be the cache, because it seems …

cereal 1,524 Nearly a Senior Poster Featured Poster

The problem is that the Yahoo API Terms of Use does not allow to store data for more then 24 hours, so, you can just cache for a day and then you have to request the data:

This means that you can still write data to Cassandra or to a memory cache as Memcached or Redis and use a cronjob to remove it after 24 hours. So: no collection, just cache.

If you're still in doubt regarding the permission to save data, then you may want to ask to the Yahoo Developer Forum:

Probably in the YQL forum or the General forum.

Regarding the script to save data from the links you posted above, you can refer to the example that I wrote to you in a previous thread:

If you've still problems then show your code.