AndrisP 193 Posting Pro in Training

maybe try

$query = "select * from manuscript where year = :year limit, :offset , :refs";
$sql = $con->prepare($query);
$offset = $page * $refs;
    $sql->bindParam(':year', $year, PDO::PARAM_INT);
    $sql->bindParam(':offset', $offset, PDO::PARAM_INT);
    $sql->bindParam(':refs', $refs, PDO::PARAM_INT);
    $sql->execute();
AndrisP 193 Posting Pro in Training

use one of

    $query = "select count(*) from manuscript where year = :year";
    $sql=$con->prepare($query);
    $sql->bindParam(':year', $year);
    $total = $sql->fetchColumn();
    echo $total;

or

    $query = "select count(*) from manuscript where year = ?";
    $sql=$con->prepare($query);
    $sql->execute([$year]);
    $total = $sql->fetchColumn();
    echo $total;

do not mixed two methods of binding variables

AndrisP 193 Posting Pro in Training

edit links:

for($x=0; $x<$pages; $x++){
       echo '<a href="index.php?page='.$x.'"
                 style="text-decoration:none">'.($x+1).'</a>';
    }

after line 10 insert line $sql->bind_param('i', $year);

AndrisP 193 Posting Pro in Training

Initialize request variables outside of function before you call it

    $year = filter_input(INPUT_GET, 'year', FILTER_VALIDATE_INT);
    $page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
    $refs = filter_input(INPUT_GET, 'refs', FILTER_VALIDATE_INT);

    getYear($year, $page, $refs);

drop lines 13 and 16-30 put new line instead:
if($page>$pages){ $page = $pages; }
elseif($page<0){ $page = 0 }
change variable name in line 14 $refs_per_page to $refs

AndrisP 193 Posting Pro in Training

show me your new version of function

AndrisP 193 Posting Pro in Training

Two similar function for different year is irrationally. I would suggest to transform getYear() and put year as parameter eg getYear($year). You can set many parameters eg getYear($year, $page, $refs) you can set default values also eg getYear($year=date("Y"), $page=0, $refs=20) then replace your query

$year = filter_input(INPUT_GET, 'year', FILTER_VALIDATE_INT);
$page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
$refs = filter_input(INPUT_GET, 'refs', FILTER_VALIDATE_INT);

$query = "select * from manuscript where year = :year limit :page*:refs,:refs";

never put request variables directly to the SQL query! - use bind variables and bind params after prepare query

$stmt = $conn->prepare($query);
$stmt->bindParam(':year', $year, PDO::PARAM_INT);
$stmt->bindParam(':page', $page, PDO::PARAM_INT);
$stmt->bindParam(':refs', $refs, PDO::PARAM_INT);
$stmt->execute();

Replace HTML links eg

<a href="index.php?year=2015&page=0">2015/1</a>
<a href="index.php?year=2015&page=1">2015/2</a>
<a href="index.php?year=2015&page=2">2015/3</a>
.....
.....
.....
<a href="index.php?year=2016&page=0">2016/1</a>
<a href="index.php?year=2016&page=1">2016/2</a>
<a href="index.php?year=2016&page=2">2016/3</a>
rproffitt commented: Well said. +11
diafol commented: Good advice +14
AndrisP 193 Posting Pro in Training

@Gribouillis Actually no its easy way to call python scripts from shell script file. Versions of Python declare in a .py file starts like #!/usr/bin/python or #!/usr/bin/python3 or other

AndrisP 193 Posting Pro in Training

You dont need python command. Make shell script executable and python scripts executable.
e.g. if you put in terminal cd /full/path/to/python "Enter" and then put a.py "Enter" then do not work but if shell record starts by slash like /full/path/to/python/a.py then it call as executable file

AndrisP 193 Posting Pro in Training

You can put all in a shell script file e.g. "run_py_files.sh"

/full/path/to/python/a.py
/full/path/to/python/b.py
/full/path/to/python/c.py
/full/path/to/python/d.py
/full/path/to/python/e.py
/full/path/to/python/f.py
/full/path/to/python/g.py

make it executable and call only one shell script

AndrisP 193 Posting Pro in Training

I think you need RIGHT JOIN something like this:

DROP TABLE IF EXISTS `products`;
CREATE TABLE `products`(
    `prod_id` INT PRIMARY KEY
    ,`prod_name` VARCHAR(30)
    ,`prod_descr` VARCHAR(90)
    ,`prod_price` DECIMAL(7,2)
    ,`prod_stock` INT
    ,`prod_date` DATE
);
DROP TABLE IF EXISTS `wish_list`;
CREATE TABLE `wish_list`(
    `wish_id` INT PRIMARY KEY
    ,`wish_account` INT
    ,`wish_item_id` INT
    ,`wish_date` DATE
);
INSERT INTO `products`(
    `prod_id`
    ,`prod_name`
    ,`prod_descr`
    ,`prod_price`
    ,`prod_stock`
    ,`prod_date`)
VALUES (16575
    ,'Product One'
    ,'This is the first product!'
    ,10,2,'2016-03-20')
    ,(573552
    ,'Product Two'
    ,'This is the second product!'
    ,5,20,'2016-03-20');
INSERT INTO `wish_list`(
    `wish_id`
    ,`wish_account`
    ,`wish_item_id`
    ,`wish_date`)
VALUES (25745735
    ,54246326
    ,16575
    ,'2016-02-29')
, (265734573
    ,54246326
    ,3143
    ,'2016-02-29');
CREATE OR REPLACE VIEW `exp_result` AS
    SELECT w.`wish_id`, w.`wish_account`
    , w.`wish_item_id`, w.`wish_date`
    , p.`prod_id`, p.`prod_name`
    , p.`prod_descr`, p.`prod_price`
    , p.`prod_stock`, p.`prod_date` 
FROM `products` p
    RIGHT JOIN `wish_list` w
    ON p.`prod_id` = w.`wish_item_id`;
SELECT * FROM `exp_result`;
AndrisP 193 Posting Pro in Training

if you want insert:

INSERT INTO tablename (col1, col2, col3) VALUES (?,?,?)

if you want update table:

UPDATE tablename SET col1 = ? , col2 = ? , col3 = ? WHERE id = ?

your example contain illegal mix of sql commands.
And do not directly put variables into SQL, use prepare and execute statement!

AndrisP 193 Posting Pro in Training

Hermelix, mark this thread as solved please

AndrisP 193 Posting Pro in Training

You mean mysqli_insert_id() ? http://php.net/manual/en/mysqli.insert-id.php

AndrisP 193 Posting Pro in Training

Sorry. parentNode in the your example is "movies".
Use child.parentNode.appendChild(newNode); or child.parentNode.insertBefore(newNode, child.nextSibling);

AndrisP 193 Posting Pro in Training

No!

NodeList movielist = doc.getElementsByTagName("movie")[0];
AndrisP 193 Posting Pro in Training

in the line 1

getElementsByTagName

is not unique selection it's a list. Try movielist[0]
or another way: child.parentNode.appendChild(newNode);

AndrisP 193 Posting Pro in Training

Line 4 replace: movielist.appendChild(newNode);
or if you want to put new node after resource to copy then check if child.nextSibling exist then movielist.insertBefore(newNode, child.nextSibling); otherwise movielist.appendChild(newNode);

AndrisP 193 Posting Pro in Training

If you define function after call it, then declare it before
e.g. put line int func_compare(int x, int y); before main()

AndrisP 193 Posting Pro in Training

void is no returns but can change input params e.g.

#include <iostream>
#include <stdio.h>

void myfunc(int &a, int &b, int &c){
    a += 1;
    b -= 2;
    c = a+b;
    return;
    }

int main(){
    int a=5,b=6,c=7;
    // print before myfunc()
    printf("a=%d b=%d c=%d \n", a,b,c);

    myfunc(a, b, c);

    // print after myfunc()
    printf("a=%d b=%d c=%d \n", a,b,c);
    return 0;
    }

result of next example will be identical

#include <iostream>
#include <stdio.h>

void myfunc(int &a, int &b, int &c){
    printf("a=%d b=%d c=%d \n", a,b,c);
    a += 1;
    b -= 2;
    c = a+b;
    printf("a=%d b=%d c=%d \n", a,b,c);
    return;
    }

int main(){
    int a=5,b=6,c=7;
    myfunc(a, b, c);
    return 0;
    }
AndrisP 193 Posting Pro in Training

Charcodes of capital letters is 65-90. Replace line 29 to if(int(str[i])>=65 && int(str[i])<=90)

AndrisP 193 Posting Pro in Training

If type of id_key is INTEGER then try set value without apostrophes

$query="UPDATE va SET id_key=$id";

or

$query="UPDATE va SET id_key=".$id;
AndrisP 193 Posting Pro in Training

add else '1' before END

AndrisP 193 Posting Pro in Training

Yes it is!

AndrisP 193 Posting Pro in Training

You can add where clause in this queries or select from stored procedure or view

AndrisP 193 Posting Pro in Training

It's a very easy - sum of column "c3" (all rows of table "t1")

SELECT SUM(`c3`) FROM `t1`;

each row sum of columns "c3", "c4", "c5"

SELECT *,(`c3`+`c4`+`c5`) AS `sum` FROM `t1`;

and total sum of columns "c3", "c4", "c5" all rows of table "t1"

SELECT *,(`c3`+`c4`+`c5`) AS `sum`,SUM(`c3`+`c4`+`c5`) AS `total` FROM `t1`;
AndrisP 193 Posting Pro in Training

Sorry, 0775 for directories and 0664 for files

AndrisP 193 Posting Pro in Training

Recursive set owner www-data for all www directories:

sudo chown -R 33 /var/www

Recursive set user group to YOU for all www directories:

sudo chgrp -R 1000 /var/www

Recursive set properties for owner and group - execute directories and read-write files, but other users read files and execute directories (lower rw and upper X set read-write files such as 0644 and execute dir such as 0755):

sudo chmod -R ug=rwX,o=rX /var/www

This 3 lines you can write in to the shell script file e.g. "properties.sh" (the file properties set executable) and call this file from command line always when you insert new files in to the /var/www

AndrisP 193 Posting Pro in Training

Is the username '1'?

AndrisP 193 Posting Pro in Training
AndrisP 193 Posting Pro in Training
preg_match('~^(\d{3}\-){2}\d{4}$~', '000-000-0000')

and don't need check strlen

AndrisP 193 Posting Pro in Training

When connected to the database immediatly set charset e.g.

$link = mysql_connect('localhost', 'root', '');
$db_selected = mysql_select_db("dbname", $link);
mysql_set_charset('utf8',$link);

or OOP version

$mysqli = new mysqli('localhost', 'root', '', 'dbname', 3306);
$mysqli->set_charset('utf8');
AndrisP 193 Posting Pro in Training
for($i=1; $i<=12; $i++){
    echo str_pad($i, 2, "0", STR_PAD_LEFT)."<br/>";
    }
AndrisP 193 Posting Pro in Training

Perhaps more convenient to use the selector instead of a text field

<select name="bodovi">
    <script type="text/javascript">
    for(var i=1; i<=50; i++){
        document.write('<option value="'+i+'">'+i+'</option>');
        }
    </script>
</select>
AndrisP 193 Posting Pro in Training

Use elseif instead if in lines 5 and 6 of my code

AndrisP 193 Posting Pro in Training
$errors = array();

// and then test for all errors
if(!ctype_digit($var)){ $errors[] = "NOT DIGIT!"; }
if($var==0){ $errors[] = "IS SET NULL!"; }
if($var==""){ $errors[] = "IS SET EMPTY VALUE!"; }
//........

if(empty($errors)){
    // statement for good user selection
    }
else {
    foreach($errors as $line){
        echo $line."<br/>";
        }
    }
AndrisP 193 Posting Pro in Training
if(!ctype_digit($var)){ echo "NOT DIGIT"; }
AndrisP 193 Posting Pro in Training

Cut and paste line 6 after the line 23

AndrisP 193 Posting Pro in Training

Line 25 replace elseif to if, lines 13, 16, 19, 22 need quotes like this:
if ($place == 'balkon')

AndrisP 193 Posting Pro in Training

I recommend to insert spaces:

<?php if($True == 0){ ?>
    <a href="/#"> Apply </a>
<?php } else { ?>
    <a href="/#"> Aleary applied </a> 
<?php } ?>
ravi142 commented: @AndrisP : Thank You. +1
AndrisP 193 Posting Pro in Training

Ok as You Like

AndrisP 193 Posting Pro in Training

Me it works perfectly. Maybe try another delimiter e.g. ||

AndrisP 193 Posting Pro in Training
DROP TRIGGER IF EXISTS after_insert_event;
DELIMITER $$
CREATE TRIGGER after_insert_event AFTER INSERT ON event
    FOR EACH ROW
    BEGIN
    INSERT INTO guest (event_id, event_name) VALUES (NEW.event_id, NEW.event_name);
    END; $$

And check your syntax also in this:

$event = mysql_query("INSERT INTO event VALUES('','$name','$dstart $tstart','$dend $tend','$venue','')") or die(mysql_error());

Where is column names?

AndrisP 193 Posting Pro in Training

trigger you write once and it is stored in the database

AndrisP 193 Posting Pro in Training

Something like this:

CREATE TRIGGER after_insert_event AFTER INSERT ON event 
FOR EACH ROW 
    BEGIN
        INSERT INTO guest (event_id, event_name) VALUES (NEW.event_id, NEW.event_name)
    END;

but your first example not correct "INSERT INTO event ????? VALUES"

AndrisP 193 Posting Pro in Training

Would not it be more convenient to use a trigger?

AndrisP 193 Posting Pro in Training

var a = str.replace(/error/,'my replace')
or
str.replace(/anything.*anything/,'anything my replace anything')
if I understand correctly

AndrisP 193 Posting Pro in Training

Cut line 2: $place = mysql_real_escape_string($_POST['place']);
and write after check isset() (line 4): if(isset($_POST['place']))

AndrisP 193 Posting Pro in Training

Maybe this useful
SELECT LPAD(CAST(myValue AS DECIMAL(4,2)), 5, '0');
The result will be:
11.5, 5.5, 2.25, 1, 12.25
AS
11.50 05.50 02.25 01.00 12.25

AndrisP 193 Posting Pro in Training

I checked again, but PHP generated dates are not always on Sunday - so wrong!
This works in C++ and it seems that the correct:

#include <sstream>
#include <iostream>


using namespace std;

string ZeroPadNumber(int num){
    stringstream ss;
    // the number is converted to string with the help of stringstream
    ss << num; 
    string ret;
    ss >> ret;
    // Append zero chars
    int str_length = ret.length();
    for (int i = 0; i < 2 - str_length; i++)
        ret = "0" + ret;
    return ret;
    }

void EasterDate(int X){                             // X = year to compute
    int K, M, S, A, D, R, OG, SZ, OE;

    K  = X / 100;                                   // Secular number
    M  = 15 + (3 * K + 3) / 4 - (8 * K + 13) / 25;  // Secular Moon shift
    S  = 2 - (3 * K + 3) / 4;                       // Secular sun shift
    A  = X % 19;                                    // Moon parameter
    D  = (19 * A + M) % 30;                         // Seed for 1st full Moon in spring
    R  = D / 29 + (D / 28 - D / 29) * (A / 11);     // Calendarian correction quantity
    OG = 21 + D - R;                                // Easter limit
    SZ = 7 - (X + X / 4 + S) % 7;                   // 1st sunday in March
    OE = 7 - (OG - SZ) % 7;                         // Distance Easter sunday from Easter limit in days

    //Easter = DateSerial(X, 3, OG + OE);           // Result: Easter sunday as number of days in March
    cout << X << "-" << ZeroPadNumber(((OG + OE)>31)?4:3) << "-" << ZeroPadNumber((((OG + OE)%31)==0)?31:((OG + OE)%31));
    }

int main ()
{
    int year;
    do {
        cout << "Put the year: ";
        cin >> year;
        EasterDate(year);
        cout << endl << endl;
        }
    while (year>0);
    return 0;
}
AndrisP 193 Posting Pro in Training

ddanbe, I compared to a built-in PHP function "easter_date()" and adjust alghoritm to C++

#include <iostream>
using namespace std;

void EasterDate(int Year)
    {
        // Gauss Calculation
        ////////////////////

        int Month = 3;

        // Determine the Golden number:
        int G = Year % 19 + 1;

        // Determine the century number:
        int C = Year / 100 + 1;

        // Correct for the years who are not leap years:
        int X = ( 3 * C ) / 4 - 12;

        // Mooncorrection:
        int Y = ( 8 * C + 5 ) / 25 - 5;

        // Find sunday:
        int Z = ( 5 * Year ) / 4 - X - 10;

        // Determine epact(age of moon on 1 januari of that year(follows a cycle of 19 years):
        int E = ( 11 * G + 20 + Y - X ) % 30;
        if (E == 24) {E++;}
        if ((E == 25) && (G > 11)) {E++;}

        // Get the full moon:
        int N = 44 - E;
        if (N < 21) {N = N + 30;}

        // Up to sunday:
        int P = ( N + 7 ) - ( ( Z + N ) % 7 );

        // Easterdate: 
        if ( P > 31 )
        {
            P = P - 31;
            Month = 4;
        }
        cout << Year << "." << Month << "." << P;
    }

int main ()
{
    int year;

    for(int i=1970; i<2038; i++){
        EasterDate(i);
        cout << endl;
        }
    return 0;
}