minitauros 151 Junior Poster Featured Poster

I don't think there is a way for us to know what the author of that script meant with $base_path. I think you should look into the rest of the script, see where it is used and try to determine in that way what its value should be.

minitauros 151 Junior Poster Featured Poster

Well, there isn't any code in there to display data, so what did you expect? ;) Did you post all of your code though? Seems like some is missing.

minitauros 151 Junior Poster Featured Poster

It is a notice. This is not a serious warning. It just tells you that you are using a variable that has not been defined yet.

Two possible fixes:
1. Turn off the reporting of notices (e.g. error_reporting(E_ALL & ~E_NOTICE); on the first line of your first script).
2. Instead of using if ($_POST['delete']), use if (!empty($_POST['delete'])).

minitauros 151 Junior Poster Featured Poster

Yes, that is because when you press "next", a new page is loaded and no post values are submitted, which means that $search will be empty on the next page load. Hence the "search term too short" message.

Stuff that gets submitted through the URL cannot be retrieved using $_POST; you need to use $_GET.

minitauros 151 Junior Poster Featured Poster

You have to be more specific. What values do you want to hide? Have you written any code yet?

minitauros 151 Junior Poster Featured Poster

Well, I'm glad you discovered the next clue ;). Let us know if you find anything that is wrong with it and if you need help with it.

minitauros 151 Junior Poster Featured Poster

You are only passing 3 arguments to your Get_All_Orderlines_Range() function, while it needs 4.

minitauros 151 Junior Poster Featured Poster

Well, if you are getting an error, it would be helpful if you would post that error so that we can see what goes wrong, where, and why :).

On top of that, I can help you build your scripts, but I cannot build your scripts for you. Have you written all the code in your first post yourself? Do you understand what is happening? If so, what do you not understand in my previous post? I'll quote that post below:

Well, obviously you need to pass on a parameter when the "next" button is pressed that tells you which page you're loading. Then you need to do page_number * results_per_page to caclulate the offset for your query.

minitauros 151 Junior Poster Featured Poster

Ok, this is confusing me somewhat: your file is in the list with included files, but if you output text inside that include file, it isn't being shown on the screen? Or does output get shown on the screen, and is it the "false" that is generated by var_dump(function_exists('Get_Favourites'));? Have you tried using different spelling for your function name and checking (with the function_exists() function) if the function does get defined properly with that spelling?

minitauros 151 Junior Poster Featured Poster

In addition to my answer, you can measure how long actions take by using - for example - the microtime function. Example:

// ----- ACTION 1: -----

$start = microtime(true);

for ($i = 0; $i < 9999; $i++) {
    // Perform action 1.
}

$end = microtime(true) - $start;
$avg_time_per_action_1 = $end / 9999;

// ----- ACTION 2: -----

$start = microtime(true);

for ($i = 0; $i < 9999; $i++) {
    // Perform action 2.
}

$end = microtime(true) - $start;
$avg_time_per_action_2 = $end / 9999;

// ----- RESULTS: -----
echo 'Avg time 1: ' . $avg_time_per_action_1 . ', 2: ' . $avg_time_per_action_2 . '<br>';
minitauros 151 Junior Poster Featured Poster

Well, usually an update query takes longer than a select query because an update query locks the database where a select query does not. Therefore, if you can avoid an update query by running a select query, it might do good to your app's performance. You will need to have use case statistics, however, to see how many times values actually remain unchanged, what the difference in impact is for both scenarios, etc., to be able to give a true answer to your question.

minitauros 151 Junior Poster Featured Poster

Well, obviously you need to pass on a parameter when the "next" button is pressed that tells you which page you're loading. Then you need to do page_number * results_per_page to caclulate the offset for your query.

minitauros 151 Junior Poster Featured Poster

Have you tried a Javascript function that uses settimeout()?

minitauros 151 Junior Poster Featured Poster

Well yes, it must be that, then. That's why I thought you could try to output var_dump(function_exists('Get_Favourites')); inside the file that defines the function (after the function is defined) to see if it really is a problem with the function definition. Have you tried that?

minitauros 151 Junior Poster Featured Poster

Ah, I see what you're probably doing wrong now. Your $construct query is ok (apart from the fact that you're not properly escaping user input). Your $getquery function is not ok, though: you insert a whole SELECT query into your WHERE clause, which is not what you want, if I look at the rest of your code. Therefore, you may want to replace your $getquery line with the following:

$query_with_limit = $construct . ' LIMIT ' . mysql_real_escape_string($start) .',' . mysql_real_escape_string($per_page);
$getquery = mysql_query($query_with_limit);

and the $run in

while($runrows = mysql_fetch_assoc($run)) // This while loop will prints search reasults,

by $getquery. Could you check if that makes a difference?

minitauros 151 Junior Poster Featured Poster

Well, it looks like only one record should be returned per page load then. Can you confirm that this loop

while($runrows = mysql_fetch_assoc($run)) // This while loop will prints search reasults,

is indead only run one time - for one search result? (Before the line, add $results_loop_counter = 0;, and at the end of the while() loop, add $results_loop_counter++;. Then, after the while() loop, add echo 'Times run: ' . $results_loop_counter . '<br>';).

minitauros 151 Junior Poster Featured Poster

Well, before they are used, you could execute some code like:

echo '<p>The value of $start is: ' . $start . ', and the value of $per_page is: ' . $per_page . '</p>';
minitauros 151 Junior Poster Featured Poster

What about you create a timer that checks every x miliseconds if the button exists, and if so, clicks it?

minitauros 151 Junior Poster Featured Poster

An unescaped dot matches any character (except a whitespace if the modifier is not set). You need to use \. to match a dot, instead of just .. Also, you can replace {1,} by + (which means the same: 1 or more).

minitauros 151 Junior Poster Featured Poster

Have you checked and validated the values of your $start and $per_page variables?

On a side note
Also, your query isn't secure. You should escape user input in queries using mysql_real_escape_string(). Better yet, you should use mysqli, because the "regular" mysql functions are deprecated.

minitauros 151 Junior Poster Featured Poster

So if you add an echo to the file that defines your Get_Favourites() function, and then include that file, nothing is being echo'd to the screen? E.g. if you add echo 'Hey, you\'ve just included me!';, it doesn't show on the screen? Because if that is the case, you simply need to make sure that your file is properly included.

minitauros 151 Junior Poster Featured Poster

Well, file_exists() does not return true if the file does not exist. That means that $target_file must exist. Can you triple check that it does not? I.e.: check the value of $target_file and output getcwd() (outputs the current working directory) and see if the file really does not exist?

minitauros 151 Junior Poster Featured Poster

Then what is it displaying? :)

minitauros 151 Junior Poster Featured Poster

Well, maybe you could add some debug code to the file that contains that function that says "Hey, you've just included me!" and after that line something like var_dump(function_exists('Get_Favourites')); to see if the function has been defined (bottom lines of the function file).

minitauros 151 Junior Poster Featured Poster

Well, if it is not in the list that is returned by get_defined_functions() there is something wrong, apparently :p. Is it in the list?

minitauros 151 Junior Poster Featured Poster

You could write it in the same place that you wrote the get_included_files() function, i.e. the line before the error.

Example: print_r(get_defined_functions()); exit();

minitauros 151 Junior Poster Featured Poster

Is the file being included before the function is called? Have you checked if there isn't a case problem (not that PHP functions are case sensitive, for as far as I know, but just to be sure)? Have you used get_defined_functions() to see if your function has actually been registered as defined?

minitauros 151 Junior Poster Featured Poster

You can check whether the correct file (the one that defines the function) has been included by executing print_r(get_included_files()); exit(); the line before the error.

minitauros 151 Junior Poster Featured Poster

Does it give any error?

minitauros 151 Junior Poster Featured Poster

Use the __construct() function. It is called when the object is instantiated (i.e. when you execute $object = new Object();.

Example:

class booking_diary {
    // Time Related Variables
    public $booking_start_time; 
    public $booking_end_time;

    public function __construct($a, $b) {
        $this->booking_start_time = $a;
        $this->booking_end_time = $b;
    }
}
minitauros 151 Junior Poster Featured Poster

Can you confirm that in your code line 84 is really $stmt->execute(); and can you confirm that $stmt is really a PDOStatement (e.g. var_dump($stmt);?

Could it be that $conn->exec($sql); is generating the error?

minitauros 151 Junior Poster Featured Poster

You're probably getting a notice that there is an undefined variable on line 4. That is because $_post does not exist. Variable names in PHP are case-sensitive. This means that you need to use $_POST (with capital letters) - this represents the values that are sent with the POST request.

You will also get a notice if an array key is undefined. That means that if $_POST['user_id'] is undefined, you will be notified of it. This is not a serious error, and you can turn the reporting of notices off with for example:

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

(from php.net)

Code that will probably work:

// Check if $_POST['user_id'] is not empty. If true is returned, assign $_POST['user_id'] to $id. Else, assign null to $id.
$id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;

(In the example above, I use the "ternary operator", see also here and scroll to "Ternary operator").

minitauros 151 Junior Poster Featured Poster
  1. Google
  2. Leads to StackOverflow
  3. You've got your answer! Which is something like:

-----

window.onbeforeunload = function (event) {
    var message = 'Important: Please click on \'Save\' button to leave this page.';
    if (typeof event == 'undefined') {
        event = window.event;
    }
    if (event) {
        event.returnValue = message;
    }
    return message;
};
minitauros 151 Junior Poster Featured Poster

Change your HTML:

 <div class="form-group">
    <label class="col-xs-3 control-label">What is your full legal name?</label>
    <div class="col-xs-5">
        <p id="user_name_container">Hello <span id="user_name"></span>, nice to meet you!</p>
        <input type="text" class="form-control" name="name" />
    </div>
 </div>

Then your Javascript (using jQuery):

$('input[name=name]').keyup(function() {
    if ($(this).val()) {
        $('p#user_name_container').show();
        $('span#user_name').html($(this).val());
    }
    else {
        $('p#user_name_container').hide();
    }
 });
minitauros 151 Junior Poster Featured Poster

Well, the error message you entered clearly states

Fatal error: Call to undefined method PDOStatement::exec() in /home/a6382499/public_html/insert3.php on line 84

that your PDOStatement object is trying to use the method exec(), which doesn't exist in a PDOStatement object. Maybe the lines aren't the same in your post as in your code file, but I think the answer to your problem may be the same: your PDOStatement object (whichever it may be) is trying to use a method that it doesn't have.

Also, why is there a $conn->exec($sql); on your line 86? It appears to be a bit useless to me, because I don't see $sql defined anywhere, and also you already execute a statement two lines above.

minitauros 151 Junior Poster Featured Poster

The PDOStatement object does not have an exec() method; that is PDO's own method (http://php.net/manual/en/pdo.exec.php). To execute a PDO statement, you need to use execute() instead of exec() (http://php.net/manual/en/pdostatement.execute.php). I understand the confusion :).

minitauros 151 Junior Poster Featured Poster

These are notices, not severe errors. You can change your error reporting to E_ALL & ~E_NOTICE if you don't want to see them. Or you can simply check for the existence of values before you try to display them. E.g. if (!empty($var)) { echo $var; }.

Also, there's a "Reply to post" button so that you can add a reply to your question, so that you don't have to start a whole new post :).

minitauros 151 Junior Poster Featured Poster

What is the error that you're getting?

You could try to add print_r($row); inside your loop so that you can see the contents of $row and see if anything is missing.

minitauros 151 Junior Poster Featured Poster

From http://php.net/manual/en/session.configuration.php :

session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and potentially cleaned up. Garbage collection may occur during session start (depending on session.gc_probability and session.gc_divisor).

I must admit that I've never looked into this any further than reading what I just quoted. Could you expand a bit more upon this subject? What does "potentially cleaned up" mean, specifically?

minitauros 151 Junior Poster Featured Poster

Well I personally don't have any experience at all with writing browsers, let alone browsers for Android :p. But for as far as writing Javascript goes.. sure you can write Javascript code for a website that will run on a phone with the specs you described. It will possibly just get a little (or a lot) slower, that's all (for as far as I know).

What is your goal, then? You're going to write a browser? Because I guess that you'd then be better off in another forum category with these questions :).

minitauros 151 Junior Poster Featured Poster

Can you show us the query that contains the error?

minitauros 151 Junior Poster Featured Poster

What about you post the query that contains the error? ;)

minitauros 151 Junior Poster Featured Poster

sessions destroy itself after 30 minutes from time created, or when user closes the browser

Since when is that so? :o

diafol commented: Reversing the downvote. Harsh wasn't it? +15
minitauros 151 Junior Poster Featured Poster

You mean that when you have multiple file inputs and select a unallowed file for more than one of those inputs, you get only errors for one of them? Or do you not get any errors at all?

minitauros 151 Junior Poster Featured Poster

When a session is completely destroyed is not always up to you. A user himself can decide when he wants to clear all website data. That can be when he closes the browser, but that can also be when he closes a tab. The only thing you have influence on is when you destroy their session, which can be, for example, when they press a "logout" button. But if you do NOT destroy their session, it will live until they clear their cookies/cache/etc.

minitauros 151 Junior Poster Featured Poster

It depends on a lot of things. On the browser side it depends on what I have already described, but your browser, obviously, is fully dependant on the system that it runs on. So if your system is for some reason slow, or if your hardware is old, your browser may not be able to work as fast as it wants. And yes, in that case, RAM speed and internet connection speed are involved, but also core processor speed, data transfer speed within the hardware system itself, and other factors as well.

minitauros 151 Junior Poster Featured Poster

When do you want those fields to have their values reset? Because looking at your code, there doesn't seem to be a problem to me: if a selects an unallowed file type for uploading, he will get an alert and the field will be rest, right? Isn't that what you want?

minitauros 151 Junior Poster Featured Poster

What's not working now? Can you post the error?

minitauros 151 Junior Poster Featured Poster

Well, I think you can have some influence on them. You can minify your CSS/Javascript files so that they take up less space, you can offer them gzipped to futher decrease the filesize, and you can write more efficient Javascript. The rest is up to the team that creates the browser.

minitauros 151 Junior Poster Featured Poster

What about using a Javascript timeout?

$('#element').click(function() {
    setTimeout(function() {
        window.location.href = 'http://website.com';
    }, 3000);
});