AndrisP 193 Posting Pro in Training

Delete space after equal sign action= "<?php echo $current_page; ?>" replace to action="<?php echo $current_page; ?>" and never use equal sign for compare username and password in the MySQL! Try this test case:

SELECT 'ABC' = 'abc','ĀBČ' = 'abc','ābč' = 'abc', 'ABC' LIKE 'abc', 
'ĀBČ' LIKE 'abc', 'ābč' LIKE 'abc', 'ABC' LIKE BINARY 'abc', 
'ĀBČ' LIKE BINARY 'abc', 'ābč' LIKE BINARY 'abc';

only "LIKE BINARY" return FALSE any other return TRUE (MySQL)

AndrisP 193 Posting Pro in Training
#define Get(x) typeid(x).name()

if I understood correctly?

AndrisP 193 Posting Pro in Training
#define Get(x) int(x)
AndrisP 193 Posting Pro in Training
void pyramid(int count){
    cin >> lineTotal;
    count = lineTotal;
    for(int line=0; line < count; line++){
        if (count >= 10){
            int width=(count-line)*2;
            if (line<9) width--;
            cout << setw( width ) << line+1;
            }
        else {
            cout << setw(count-line) << (line+1);
            }

        for(int leftside = line; leftside > 0; leftside--){
            cout << setw(count>9&&leftside!=9?2:1) << leftside;
            }
        for(int rightside = 1; rightside <= line; rightside++){
            cout << setw(count>9?2:1) << (rightside + 1);
            }
        cout << endl;
        }
    cout << endl;
    }
AndrisP 193 Posting Pro in Training
#include <iostream>
#include <iomanip>

using namespace std;

void piramid(int count){
    setfill(" ");
    for(int i=0; i<count; i++){
        cout << setw(count-i) << (i+1);
        for(int j=i; j>0; j--){ cout << j; }
        for(int j=1; j<=i; j++){ cout << (j+1); }
        cout << "\n";
        }
    cout << "\n";
    }


int main(){
    piramid(1);
    piramid(2);
    piramid(4);
    piramid(6);
    piramid(9);
    return 0;
    }
AndrisP 193 Posting Pro in Training

in example:

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

void examplefunction(int a, int b, char c){
    switch (c){
        case '+': printf("%d + %d = %d\n", a,b,a+b); break;
        case '-': printf("%d - %d = %d\n", a,b,a-b); break;
        case '*': printf("%d * %d = %d\n", a,b,a*b); break;
        case '/': printf("%d / %d = %d\n", a,b,a/b); break;
        }
    }

int main() {
    examplefunction(9,3,'+');
    examplefunction(9,3,'-');
    examplefunction(9,3,'*');
    examplefunction(9,3,'/');
    return 0;
    }
AndrisP 193 Posting Pro in Training
var txtusername = document.getElementById('txtusername').value;
$.post('index.php',{isitinDB:txtusername},
    function(data){return data;});

and index.php

<?
if(isset($_POST['isitinDB'])){
    /* check in db $_POST['isitinDB'] and return true or false */
    exit();
    }

?>
AndrisP 193 Posting Pro in Training

In HTML5 you can use attribute "required" to <input type="text" required="required" /> and <input type="password" required="required" /> instead of your js function

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

if you want to set default values to (0,0) then replace lines 9 and 10 to this

        Point(int new_x=0, int new_y=0) { set(new_x, new_y); }
AndrisP 193 Posting Pro in Training

I don't know what your function returns, but maybe this will help

<!DOCTYPE html>
<html lang="lv">

<head>
<title>TEST-PAGE</title>

<style type="text/css">
#test_0 { background:#FFFF00; }
#test_1 { background:#00FFFF; }
#test_2 { background:#FF00FF; }
#test_0 , #test_1 , #test_2 { height:200px; }
</style>

<script language="javascript" type="text/javascript" src="scripts/jquery.2.1.1.js"></script>
<script language="javascript" type="text/javascript">
function testfunc1(){
    $('#test_0').html('');
    $.when(
        $.get( "index.php", {param:"test"}, function(data){
            $('#test_0').html(data);
            }),
        $( '#test_0' ).slideUp(1000),
        $( '#test_0' ).slideDown(1000)
        ).then(
        function(){
            $.when(
                $( '#test_1' ).slideUp(1000),
                $( '#test_1' ).slideDown(1000)
                ).done(
                function(){
                    $( '#test_2' ).slideUp(1000),
                    $( '#test_2' ).slideDown(1000)
                    }
                )
            }
        );
    }

function testfunc2(){
    $('#test_0').html('');
    $.get( "index.php", {param:"test"}, function(data){
        $('#test_0').html(data);
        });
    $( '#test_0' ).slideUp(2000);
    $( '#test_0' ).slideDown(2000);
    $( '#test_1' ).slideUp(2000);
    $( '#test_1' ).slideDown(2000);
    $( '#test_2' ).slideUp(2000);
    $( '#test_2' ).slideDown(2000);
    }

</script>
</head>

<body>
    <input type="button" onclick="testfunc1()" value="test 1" />
    <input type="button" onclick="testfunc2()" value="test 2" />
    <div id="test_0"></div>
    <div id="test_1"></div>
    <div id="test_2"></div>
</body>

</html>

And index.php containing only one line

<?php
if(isset($_GET['param'])){ sleep(6); echo $_GET['param']; exit(); }
?>

Function testfunc1() wait response from index.php (in PHP example 6 seconds sleep). Function testfunc2() don't wait response.

AndrisP 193 Posting Pro in Training
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

Read this topic: Click Here

AndrisP 193 Posting Pro in Training

if this <?=$row['id'];?> don't work
then replace to <?php echo $row['id']; ?>

AndrisP 193 Posting Pro in Training

it is not correct elements with the same ID in the one document

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
{ ?>
<h4>Numero:<?=$row['id'];?></h4>
<h4>Data:<?=$row['date'];?></h4>
<h4>Ditta:<?=$row['category'];?></h4>
<p><input type="submit" name="submit" id="submit" class="btn btn-primary" value="Stampa" onclick="window.location='invoice.php?id=<?=$row['id'];?>';" />
<input type="submit" name="submit" id="submit" class="btn btn-primary" value="Modifica" onclick="window.location='edit.php?id=<?=$row['id'];?>';" />
<input type="submit" name="submit" id="submit" class="btn btn-primary" value="Cancella" onclick="confirm('Are you sure?')?window.location='delete_article.php?id=<?=$row['id'];?>':alert('Cancelled');" /></p>
<?php } ?> 

Type of button better replace to button type="button" thear is not form submit, attributes name and id they are unnecessary

AndrisP 193 Posting Pro in Training

You can replace line 10 to } ?> line 11 to <h4>Numero:<?=$row['id'];?></h4> without "echo" etc.
Line 17 replace to <?php }

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 isn't problem

<?php for($i=0; $i<10; $i++){ ?>
<input type="button" />
<?php } ?>
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

Close PHP tag and put this button without echo

?>
<input type="submit" name="submit" id="submit" class="btn btn-primary" value="Cancella" onclick="confirm('Are you sure?')?window.location='delete_article.php?id=<?=$row['id'];?>':alert('Cancelled');" />
<?php

and then open PHP tag again

AndrisP 193 Posting Pro in Training
<input type="submit" name="submit" id="submit" class="btn btn-primary" value="Cancella" onclick="confirm('Are you sure?')?window.location='delete_article.php?id=<?=$row['id'];?>':alert('Cancelled');" />
AndrisP 193 Posting Pro in Training

You can use stored procedure e.g.

DROP PROCEDURE IF EXISTS `myupdate`;

DELIMITER $$
CREATE PROCEDURE `myupdate`()
BEGIN
    DECLARE var1 VARCHAR(10);
    DECLARE var2 VARCHAR(10);
    DECLARE e BOOLEAN DEFAULT TRUE;
    DECLARE mycurs CURSOR FOR SELECT t2.c1, t3.c1 FROM t2, t3 WHERE t2.c2 = t3.c2;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET e = FALSE;
    MP: BEGIN
        OPEN mycurs;
        WHILE e DO
            IF e THEN
                FETCH mycurs INTO var1, var2;
                INSERT INTO t1 (c1, c2) VALUES (var1, var2);
            END IF;
        END WHILE;
        CLOSE mycurs;
    END MP;
  COMMIT;
END;
$$

CALL `myupdate`();

but this example is for INSERT. If you need update then replace line INSERT to UPDATE with WHERE clause

AndrisP 193 Posting Pro in Training

You selected variables from t2 and t3 by the where clause, but thear miss WHERE clause to table 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

This code check for SPACE in value:

document.form1.NEGERI.value==' '

but this check for empty value:

document.form1.NEGERI.value==''
AndrisP 193 Posting Pro in Training

Select count of male:

SELECT COUNT(*) FROM mydatatable WHERE gender = 'male'

and select count of female:

SELECT COUNT(*) FROM mydatatable WHERE gender = 'female'
AndrisP 193 Posting Pro in Training

Alt+F4 works in all Windows OS and other OS like Linux (maybe all OS).

AndrisP 193 Posting Pro in Training

I don't understand why you want to encrypt a unique ID

AndrisP 193 Posting Pro in Training

Is the username '1'?

AndrisP 193 Posting Pro in Training

Something like this:

<label for="ch_p">use BLYEAR</label>
<input id="ch_p" type="checkbox" onchange="this.nextSibling.disabled=(this.checked?false:true)" 
        <?php if(isset($_GET['p'])){ echo " checked"; } ?> /><select name="p" <?php if(!isset($_GET['p'])){ echo " disabled"; } ?> >
    <option value=".....">.....</option><!-- All values from DB for this opt if selected or not selected other params -->
</select>
<label for="ch_q">use DEPARTMENT</label>
<input id="ch_q" type="checkbox" onchange="this.nextSibling.disabled=(this.checked?false:true) 
        <?php if(isset($_GET['q'])){ echo " checked"; } ?> />" /><select name="q" <?php if(!isset($_GET['q'])){ echo " disabled"; } ?> >
    <option value=".....">.....</option><!-- All values from DB for this opt if selected or not selected other params -->
</select>
<label for="ch_r">use SUBDEPT</label>
<input id="ch_r" type="checkbox" onchange="this.nextSibling.disabled=(this.checked?false:true) 
        <?php if(isset($_GET['r'])){ echo " checked"; } ?> />" /><select name="r" <?php if(!isset($_GET['r'])){ echo " disabled"; } ?> >
    <option value=".....">.....</option><!-- All values from DB for this opt if selected or not selected other params -->
</select>

and php like this:

$params = array();
    if(isset($_GET['p'])){ $params[] = "BLYEAR='".$_GET['p']."'"; }
    if(isset($_GET['q'])){ $params[] = "DEPARTMENT='".$_GET['q']."'"; }
    if(isset($_GET['r'])){ $params[] = "SUBDEPT='".$_GET['r']."'"; }
if(count($params)>0){
    $a = "SELECT * FROM wf_workflow.pmt_detailreport WHERE ".@implode(" AND ", $params)."; ";

    $result = mysql_query($a,$con) or die(mysql_error());
    $ret = '';
    while ($row = mysql_fetch_array($result)) { 
        $ret .= (empty($ret) ? '' : ', ') .   "{'APP_NUMBER' : '{$row['APP_NUMBER']}', 
        'DRIVERNAME' : '{$row['DRIVERNAME']}','INSP_NAME_LABEL' : '{$row['INSP_NAME_LABEL']}','INSP_DATE' : '{$row['INSP_DATE']}','DEPARTMENT' : '{$row['DEPARTMENT']}','SUBDEPT' : '{$row['SUBDEPT']}'}";
        }
    mysql_close($con);
    die('[' . $ret . ']');
    }
AndrisP 193 Posting Pro in Training

I think 3 tables

SELECT
    (SELECT value FROM fruits WHERE value='Apple' LIMIT 1) as fruit ,
    (SELECT value FROM countries WHERE value='China' LIMIT 1) as countrie ,
    (SELECT value FROM sizes WHERE value='Small' LIMIT 1) as size;
AndrisP 193 Posting Pro in Training

I think you need 3 tables instead of 3 columns e.g.
Fruits, Countries, Sizes

AndrisP 193 Posting Pro in Training

Attribute name="submit" always for submit button. And check your HTML syntax - where starts <table> ?

gabrielcastillo commented: The name attr for submit inputs can be anything. -1
AndrisP 193 Posting Pro in Training

Show your script please

AndrisP 193 Posting Pro in Training
session_start();
    if ( isset($_POST['name']) ){
            $_SESSION['first_name'] = $_POST['name'];
            }

    $first name = ( isset($_SESSION['first_name']) ? $_SESSION['first_name'] : "");

    echo $first name;
AndrisP 193 Posting Pro in Training

Third example - wrong SQL query: && replace to AND

AndrisP 193 Posting Pro in Training
AndrisP 193 Posting Pro in Training

It working perfectly for me with
DEV C++ 5.6.3
General: TDM-GCC 4.8.1 64-bit Release
Executing g++.exe...

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

In sql query ` (ASCII-96) and ' (ASCII-39) not the same sense!
Use (ASCII-96) for table names and field names but (ASCII-39) for values (line 24)

AndrisP 193 Posting Pro in Training

Your postcode datatype is string but you check integer $i in array of string in line 36.
You put array as label of checkbox in lines 38 and 42 label.
I recommend replace lines 34-44 with this:

    for( $i=0; $i <$max; $i++ )
    {
        $checked = ( ( /* put correct test here */ ) ? " checked=\"checked\"" : "" );  
            echo '<input type="checkbox" name="postcode[]" value="'.$selected[$i].'"'.$checked.' id="c_'.$i.'" /><label for="c_'.$i.'">'.$selected[$i].'</label>';
    }//close for loop
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

JOIN tables, if the second table supplements the entries from the first table or UNION tables if the tables have the same structure