Gideon_1 15 Junior Poster

Have you executed this query in the mysql client or phpmyadmin

Gideon_1 15 Junior Poster

@zagga, the file is only stored in the temporary location on the server so unless you give it a permanent location is not uploaded yet.

Gideon_1 15 Junior Poster

@showman, If I were in your shoes, to think of security and flexibility, I will upload the file to my server for the first instance, then when the verification of the initial form data has returned true. I will just link to the uploaded file as an attachment to the email.

Gideon_1 15 Junior Poster

Check simple mvc tutorials from Alex Garrett at phpacademy on youtube.

Gideon_1 15 Junior Poster

are you trying to insert into the database with the select statement or ...?

Gideon_1 15 Junior Poster

$q = "SELECT user_id, fname, user_level FROM members WHERE (email='$e' AND psword=SHA1('$p'))";

Why don't you hash psword separately and try again.

so
$psword = SHA1($p);

before

$q = "SELECT user_id, fname, user_level FROM members WHERE (email='$e' AND psword=$psword";

Gideon_1 15 Junior Poster

What is the real error you are having? and If not a real error echo your sessions out and see whether they are working.

Gideon_1 15 Junior Poster

Yes I agree with pritaeas, using mysql keywords as raw text renders your sql statement invalid. For my personal preference I usually like using column names nested in back ticks. Try this.

$decline = $dbh->prepare("UPDATE users SET `status` = ? WHERE `name` = ?, `username` = ?, `email` = ?, `phone` = ?");
Gideon_1 15 Junior Poster

You are welcome, but don't forget to mark it as solved.

Gideon_1 15 Junior Poster

You are welcome, don't forget to mark discussion as solved.

Gideon_1 15 Junior Poster

I agree perfectly with pritaeas. I will advice you to go and learn the basis of php and programming. But since you are a beginner, I thought of refreshing myself with your problem. I have commented it very well for you to understand. Try it and I hope it solved your problem.

<?php
    //this is the set of numbers
    $numbers = 1432;

    //getting the number of characters(length) of the set of numbers
    $num_length = strlen($numbers);

    //Will be using substr so setting the offset to zero
    $i = 0;

    //intialising the sum variable.
    $sum = 0;

    //executing the loop
    while ($i < $num_length) {
        //adding up numbers till the last one
        $sum += substr($numbers, $i, 1);

        //incrementing $i(offset) each time the a number is added
        $i++;
    }

    //outputting the total results.
    echo $sum;
?>
Gideon_1 15 Junior Poster

In your question you said, in the console this appears : Uncaught SyntaxError: missing ) after argument list page.php:64, but the codes you have posted ends on line 52. Can you please show all your codes?

Gideon_1 15 Junior Poster

@Trabelsi, I should not be talking for everyone but it seems you have not specified the exact problem you are having. Please specify the exact difficulty you are having. It's like you just posting your codes but there's no question. We are all willing to help one way or the other if the question is clear.

Gideon_1 15 Junior Poster

I think you have an issue with the uploads. try changing this

$csvFile1 = $_FILES["file1"];

to

$csvFile1 = $_FILES["file1"]["tmp_name"];

Gideon_1 15 Junior Poster

Justin_14, this is a setting in php.ini file. If you have controll of the php.ini file, change memory limit form 64M or 32M to 128M(Maximum Limit).

If not try overriding the php.ini configurations with you .htaccess file in you public folder. Use this instead

php_memory_value_limit 128M

Gideon_1 15 Junior Poster

I totally agree with jkon, OOP is OOP in your style. But there are a few things you should also know which will help in your life of programming. This include errors you made in both PHP and HTML. (NOTE: reference XHTML, PHP5 and My Personal Interests).

  1. The inclusion of the class in the same file as other php and html codes does not encourage the idea of OOP. Usually create a file to contain only the Class or group of classes, then you include them on the page they will be needed. You can also use spl_autoload to load your classes without having to include them one by one.

  2. In your if statement, the codes should have been in parenthesis which shows that if the condition is correct run this specific codes.

  3. HTML attributes should have their values placed in double quotation marks. You did some right and left a massive number of them. I recommend you to do that if you want your projects to be of the W3C standards.

  4. You could have made your codes shorter and more readable by making the width and length arguments or parameters of the methods of the class. (Personal Preference).

  5. Indenting of codes is a good practice if you want to become an elite programmer. Always indent your codes to produce neat work.

  6. I don't know how you understand labels and their ids. The label id must be equal to the input field's id. (The field you want to address the …

Gideon_1 15 Junior Poster

Yes, I agree with pritaes, when executing sql in phpmyadmin and when there is an error it shows the place where the error is occuring.

Example

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '13' at line 1
Gideon_1 15 Junior Poster

@ribrahim include the invoice->additem in the foreach or while loop

Gideon_1 15 Junior Poster

@ribrahim, your codes are correct is just that you must include the results in a foreach statement. So here goes the codes;

   while ( $rows = mysqli_fetch_assoc($result)){
                        $description = $rows['ChargesTitle'];
                        $quantity = $rows['itemqty'];
                        $Official = $rows['itemAmountO'];
                        $Professional = $rows['itemAmountP'];
                        $discountAmount = $rows['discountAmount'];
                        $discount = number_format($Professional, 2, '.', '') * $quantity *(($discountAmount)/100);
                        $itemAmount = number_format($Official, 2, '.', '') + number_format($Professional, 2, '.', '');
                        $lineTotal = ($itemAmount * $quantity) - ($discount);
}

Or

   foreach (mysqli_fetch_assoc($result) as $rows){
                        $description = $rows['ChargesTitle'];
                        $quantity = $rows['itemqty'];
                        $Official = $rows['itemAmountO'];
                        $Professional = $rows['itemAmountP'];
                        $discountAmount = $rows['discountAmount'];
                        $discount = number_format($Professional, 2, '.', '') * $quantity *(($discountAmount)/100);
                        $itemAmount = number_format($Official, 2, '.', '') + number_format($Professional, 2, '.', '');
                        $lineTotal = ($itemAmount * $quantity) - ($discount);
}
Gideon_1 15 Junior Poster

First of all, why are you using two database connection layers in one script; mysql and mysqli. Please, I encorage you to use mysqli since mysql is deprecated.

Also I think you should be precise of the form method you are using so that you don't just use $_GET or $_POST.

But to your question, it seems you are updating the table against a field called req_code. I will advise you to update your database tables using primary keys (usually id's are used as primary keys in the database).

In your example, it can be possible that, that req_code is the same across all fields in the database. But for id's (primary key), it can never be the same.

So if you don't have an id or primary key field, you go ahead and create one and then update your rows where id = userid.

Gideon_1 15 Junior Poster

Yh I agree with todyITguy, learning it will be of great help but if you are in need seriously you can use these ajax codes;

        <script type="text/javascript">
            function load () {
                var xmlhttp = new XMLHttpRequest ();

                xmlhttp.onreadystatechange = function () {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                        document.getElementById('ajax').innerHTML = xmlhttp.responseText;
                    }
                }

                xmlhttp.open ('GET', 'your_php_file.php', true);
                xmlhttp.send ();
            }
        </script>

Here, you can change the php file url to a get method by getting the values of the input fields you will use for the query. Here you will use something like

`'your_php_file.php?value1='.document.getElementById('input_field1_id').value.'&value2='.document.getElementById('input_field2_id').value`

So the onchange event will send the input fields asynchronously to the php file which will perform the query and send it back to the current page.

So don't forget to create an empty div with the id ajax or anything but i prefer using ajax.

so on the php file you get the values with the $_GET superglobal

so

    $value1 = $_GET['value1'];
    $value2 = $_GET['value2'];

and then you do your query. Everything you echo out or display will be displayed in the ajax div on the current page.

Gideon_1 15 Junior Poster

To clarify things when you were encrypting the password during registration, I hope you stored the salt which was added to the password during the encryption in the database.

Gideon_1 15 Junior Poster

I don't get what you are trying to express. Your first script has no relation to the second one. Can you express yourself vividly?

Gideon_1 15 Junior Poster

try echoing out the mysqli_num_rows($query_get)

Gideon_1 15 Junior Poster

You have made many mistakes of which include
1. Setting Form action to POST but using GET in PHP
2. Did not initialize mysqli connection
3. Were not sorting output by any column but instead you used a function.

Try these codes and make changes to it so it matches with your credentials

<form name="form1" method="POST" action="status_rep.php">
    <label>
        <p>Select Month</p>
        <p class="info">
            <select name="month">
                <option value="1">January</option>
                <option value="2">February</option>
                <option value="3">March</option>
                <option value="4">April</option>
                <option value="5">May</option>
                <option value="6">June</option>
                <option value="7">July</option>
                <option value="8">August</option>
                <option value="9">September</option>
                <option value="10">October</option>
                <option value="11">November</option>
                <option value="12">December</option>
            </select>
        </p>
    </label>

    <div class="clear"></div>

    <label>
        <p>Select Year</p>
        <p class="info">
            <select name="year">
                <option value="2014">2014</option>
                <option value="2015">2015</option>
                <option value="2016">2016</option>
                <option value="2017">2017</option>
                <option value="2018">2018</option>
                <option value="2019">2019</option>
                <option value="2020">2020</option>
                <option value="2021">2021</option>
                <option value="2022">2022</option>
                <option value="2023">2023</option>
                <option value="2024">2024</option>
                <option value="2025">2025</option>
                <option value="2026">2026</option>
            </select>
        </p>
    </label>

    <div class="input" style="text-align:center;">
        <input type="submit" value="View" class="btn1" name="show" />
    </div>
</form>

<div class="clear"></div>

<?php
    if(isset($_POST['month']) && isset($_POST['year'])) {
        $month = intval($_POST["month"]);
        $year  = intval($_POST["year"]);
    } else {
        $month = date("m");
        $year  = date("Y"); 
    }


    echo "<script language = 'javascript'>
             form1.month.options[",$month-1,"].selected = true;
             form1.year.options[",$year-2014,"].selected = true;
         </script>";


    $startday = 1;

    //endday for months with 31 days
    if($month==1 || $month==3 || $month==5 || $month==7 || $month==8 || $month==10 || $month==12) {
        $endday = 31;
    }

    //endday for months with 30 days
    if($month==4 || $month==6 || $month==9 || $month==11) {
        $endday = 30;
    }

    //endday for february
    if($month==2) {
        if($year%4==0) {
            $endday = 29;
        }else {
            $endday = 28;
        }
    }
    $date1 = $year . "-" . $month . "-" . …
Gideon_1 15 Junior Poster

Your are still using ORDER BY DATE instead of p_date. Also you can save you fetch_assoc to an array and use fetch assoc to ouput the data which will be relevantly fast than echoing every thing bit by bit when dealing with huge amount of data.

Gideon_1 15 Junior Poster

In addition, try to use mysqli or PDO since mysql extension has been deprecated since PHP 5.0.