minitauros 151 Junior Poster Featured Poster

On the first line of your file with the error, type 'use strict' followed by a newline. That should fix it. Some stuff in Javascript is only supported if you use strict mode.

minitauros 151 Junior Poster Featured Poster

Yes it does.

(function($) {

    // Code

})(jQuery);

simply defines an anonymous function and executes it right away, passing it jQuery as argument for $. You can put everything inside there.

minitauros 151 Junior Poster Featured Poster

I know, that's why I posted the solution above. Look at it again ;). Do you see a document.ready anywhere?

minitauros 151 Junior Poster Featured Poster

JOIN works if tables have different column names.

Example:

SELECT table_a.name, table_b.username FROM table_a JOIN table_b ON table_a.user_id = table_b.user_id WHERE table_a.user_id = 1

In the ON part of the query you tell the query which column in the first table matches the which column in the second table.

cereal commented: +1 +13
diafol commented: +1 +15
minitauros 151 Junior Poster Featured Poster

Why don't you use a JOIN? :)

shany0786 commented: thnks for reply does join work if have table having some columns different names.can you give link how to use it +0
minitauros 151 Junior Poster Featured Poster

"Have you tried turning it off and on again?"

Kidding, but seriously, if this is a new installation, just reinstall and it will probably fix your problems.

minitauros 151 Junior Poster Featured Poster

You could place your functions inside an anonymous functions like so:

(function($) {

    $('#fancy_jquery_element').doFancyStuff();

})(jQuery);
minitauros 151 Junior Poster Featured Poster

Mate, do you have any idea what you are doing at all? :P What is is that you are trying to do? Are you trying to get an array of unique phone numbers or are you trying to output a comma separated list? Because if it is the latter, the only thing you'd need is echo implode(',', $_POST['numbers']);.

minitauros 151 Junior Poster Featured Poster

I only included the PHP to remove the duplicate numbers. You will have to print them yourself ;).

minitauros 151 Junior Poster Featured Poster

Ok because I do not fully understand from which directory you are calling your scripts, let's make clear we're on the same line here :).

So let's say you have directory C:\wamp\www\x. In x, you have src\autoload.php, i.e. C:\wamp\www\x\src\autoload.php. So when you are now inside directory x in your terminal, calling phpunit --bootstrap src/autoload.php tests/MoneyTest directs to folder src in your current folder, and to autoload.php in the src folder. Is this what you are trying, and is this where you are getting your "autoload.php cannot be opened" message?

minitauros 151 Junior Poster Featured Poster

Your code with comment:

$myarray = array();
$myarray['numbers']=$_POST['numbers'];
foreach($myarray as $num){
       $numbers=$num; // You aren't creating an array here. You are giving $numbers the value of the CURRENT number in the loop. PLUS your numbers are stored in $myarray['numbers'], not in $myarray ;).
}
$unique = array_unique($numbers); 
$output=implode("<br />",$unique);

What it should be:

// Assign $_POST['numbers'] to $numbers if it exists, otherwise make it an empty array.
$numbers = !empty($_POST['numbers']) ? $_POST['numbers'] : array();

// Output the result.
$output = implode('<br>', array_unique($numbers));

Nice find on the array_unique by the way :). If you need more explanation, let me know! Some explanation on the $var = $condition ? true : false line I used:

// This line..
$numbers = !empty($_POST['numbers']) ? $_POST['numbers'] : array();

// ..is shortcode for:
if (!empty($_POST['numbers'])) {
    $numbers = $_POST['numbers'];
}
else {
    $numbers = array();
}
minitauros 151 Junior Poster Featured Poster

Well first thing that comes to mind: did you check if src/autoload.php points at something that exists from the directory you're in? :p And do you have permission to read it?

minitauros 151 Junior Poster Featured Poster

So if there is more than one occurence of the same product with the same percentage, you don't want it listed?

minitauros 151 Junior Poster Featured Poster

Sorry, forgot to explain that other bit. Thanks Diafol! Nice addition.

minitauros 151 Junior Poster Featured Poster

Well, a quick search on Google seems to result in an answer to your question.

See http://stackoverflow.com/questions/3366895/group-by-month-and-year-in-mysql

minitauros 151 Junior Poster Featured Poster

You can't specify target table 'telefonisti_podaci' for update in FROM claus

This looks like a non-default MySQL error. Maybe it's a custom error triggered by your CustomQuery function? If so, then you could check that function to see when and thus why it is thrown/given.

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

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

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 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

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

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

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

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

minitauros 151 Junior Poster Featured Poster

Could you post what's on line 142?

minitauros 151 Junior Poster Featured Poster

What about something like:

<?php
if ($user_role == 'superadmin') {
    // Select superadmin and admin users.
    $query = 'SELECT * FROM users WHERE role = "superadmin" OR role = "admin"';
}
elseif ($user_role =='admin') {
    // Select only admin users.
    $query = 'SELECT * FROM users WHERE role = "admin"';
}

// Execute the query

(This is just an example, you should of course fill in the var names and field names and table names you want to use).

minitauros 151 Junior Poster Featured Poster

Ok so let me first rephrase your answer so that I'm sure I understand it correctly.

What you want is:
(1) When an admin is logged in, he may only see users that are "admin".
(2) When a superadmin is logged in, he may see users that are either "admin" or "superadmin".

Is this correct?

minitauros 151 Junior Poster Featured Poster

Well, even though you are setting error messages, you don't check if those error messages are set anywhere, and you don't generate an error based on the error messages. So in your code, it seems to me that it is a waste of lines, time and resources to even set them :p. You should generate/throw errors instead of just setting error messages. The error message you are seeing, is because the mail() function is giving an error, since that's the only thing that's being checked in the if/else.

I've added the error check in the example below:

<?php
if ($_POST["submit"]) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $contactno = $_POST['contactno'];
    $city  = $_POST['city'];
    $datepicker = $_POST['datepicker'];
    $persons = $_POST['persons'];
    $message = $_POST['message'];
    $from = 'Demo Contact Form';
    $to = 'imti321@gmail.com';
    $subject = 'Message from Contact';
    $body = "From: $name\n E-Mail: $email\n Ph-No:$contactno\n City:$city\n Date:$datepicker\n No-Of-Persons:$persons\n Message:\n $message ";

    $errors = array();

    // Check if name has been entered
    if (!$_POST['name']); {
        $errors[] = 'Please enter your name';
    }
    // Check if email has been entered and is valid
    if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)); {
        $errors[] = 'Please enter a valid email address';
    }
    //Check if message has been entered
    if (!$_POST['message']); {
        $errors[] = 'Please enter your message';
    }
    //  Check if simple anti-bot test is correct
    if ($human !== 5); {
        $errors[] = 'Your anti-spam is incorrect';
    }

    // Check for errors!
    if ($errors) {
        echo '<p class="errors">';
        foreach ($errors as $error) {
            echo 'Error: ' . $error . …
minitauros 151 Junior Poster Featured Poster

I don't really get what you're asking here. What exactly is is that you want help with? Writing PHP to display records? Then you'd have to be a bit more specific about what information you want to display. So could you clear up your question a bit?

minitauros 151 Junior Poster Featured Poster

You can't. You would have to either have to lock down your website for everyone or leave it open to everyone. And a website that is publically accessible will be readable and will thus be copyable.

You can try to prevent some stuff by disabling right mouse clicks, for example, but you really cannot prevent all copying, as long as the HTML source code can be read (and it can, if your website is publically accessible).

minitauros 151 Junior Poster Featured Poster
<?php
$min = 0;
$max = 100;
$random_number = mt_rand($min, $max);
printf('Your random number is %d', $random_number);
minitauros 151 Junior Poster Featured Poster

First of all: do you get an error, or does the mail simly not arrive?

Second: you don't have to enclose the variables you pass to the mail() function in quotes. So:

mail("$sendto","$thesubject","$emessage","$eheaders");

could/should become:

mail($sendto, $thesubject, $emessage, $eheaders);

Third: your $thesubject variable does not seem to contain a value - it appears not to get set. Did you check this? I don't know if it's required to have it set, but well, you could try at the least if it makes a difference :).

minitauros 151 Junior Poster Featured Poster

That is because your "mouseout" event is bound as soon as the user mouseovers your image. So if a user mouses over the image 100 times, the "mouseout" event will be bound 100 times. If you follow the example I provided, your problem should be fixed :).

minitauros 151 Junior Poster Featured Poster

Well, if you bind an event inside another event, i.e. binding the mouseout event as soon as the user mouseins, it means that the event will be bound every time the user mouseins.

That means that you in your current situation, you are actually saying:

When the user's mouse hits the image, bind the event "mouseout" to the image. And when the user's mouse hits the image again, the same event is bound to it again and again and again. Not sure if it is bound until infinity, but that seems to be where the problem lies in your case (please do correct me if I'm wrong, cause while writing this I'm becoming a bit unsure about if this is really the problem).

What you should do is move the mouseout event to outside the mousein event.

E.g.:

var img=document.getElementById('newImg');

img.addEventListener('mouseover',function(e){
    e.target.width+=200;
    console.log(e.target.width);
},false);

img.addEventListener('mouseout',function(e){
    e.target.width-=200;
    console.log(e.target.width);
},false);

I think that should fix it.

minitauros 151 Junior Poster Featured Poster

Why do you have your mouseout event listener inside the other event listenere in the first place? :p

minitauros 151 Junior Poster Featured Poster

I think you may want to style the <td> borders instead of the <table> borders to get what you're looking for. So:

table#adminTable
td {
    border: 1px solid #e2e0e0;
}
minitauros 151 Junior Poster Featured Poster

You should not use that exact example, but modify it to your own needs. Or did you do that already and is it still not working?

minitauros 151 Junior Poster Featured Poster

Why don't you just select the product merely by the product code? Or isn't that unique?

E.g.

foreach($_SESSION['products'] as $key => $cart_item) {
    if($product_code == $_GET['product_code']) {
        //* This is the product of which we're reducing the quantity.

        // Substract one (or whatever you want) from the quantity.
        $cart_item['quantity'] -= 1;

        // Save the product in its session variable.
        $_SESSION['products'][$key] = $cart_item;
    }
}
minitauros 151 Junior Poster Featured Poster

I don't think I fully understand your question. Could you give us some more background info? Like the table structure and the queries you are using? :)

minitauros 151 Junior Poster Featured Poster

What is the query that you are using to delete the record? Are you not in a transaction that is cancelled and rolled back? Some background info (queries) would not be misplaced here :).

minitauros 151 Junior Poster Featured Poster

Does either of those statements return true or 1 or anything that is not null or false? If yes, then your || operator is working for sure :).

minitauros 151 Junior Poster Featured Poster

The inputs will indeed need new names. Maybe you could add square brackets to the names, to make them an array? PHP will be able to work with that. Example:

$(document).ready(function()
{
    $('select[name=options]').change(function()
    {
        var number_of_forms_to_create = $(this).val();
        var form = $('form#form1').clone();
        var target = $('div#test');

        for(var i = 0; i < number_of_forms_to_create; i++)
        {
            var clone = form.clone();

            // Unset the form ID.
            clone.attr('id', '');

            clone.prependTo(target);
        }
    });
});

The input names should be changed to, for example, "name[]" and "email[]".

minitauros 151 Junior Poster Featured Poster

Might be that your webhost has register_globals enabled. Register_globals is deprecated since PHP 5.3, so if this is the case, your webhost is running an older PHP version. I guess you can see if register_globals is turned on or off by using phpinfo(), but I'm not sure.