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

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

I've cleared up some code for you as it seems to be in random order. Try this out and let us know what the debug messages say, as your code does not appear to be wrong at first glance.

<input type="file" name="ft_img" style="margin: 0 !important;"><input type="file" name="download" style="margin: 0 !important;">

<?php
// Image 1
$imgname1 = $_FILES["ft_img"]["name"];
$imgtype1 = $_FILES["ft_img"]["type"];
$imgtemp1 = $_FILES["ft_img"]["tmp_name"];
$path1 = "./uploads/".$imgname1;
$status = move_uploaded_file($imgtemp1, $path1);

// Debug image 1:
printf(
    'Image 1 should have been moved from %s to %s. $status = %s',
    $imgtemp1,
    $path1,
    $status ? 'true' : 'false'
);

// Image 2 (download)
$download  = $_FILES["download"]["name"];
$file_type = $_FILES["download"]["type"];
$file_temp = $_FILES["download"]["tmp_name"];
$file_path1 = "./uploads/".$download;
$status = move_uploaded_file($file_temp, $file_path1);

// Debug image 2:
printf(
    'Image 2 should have been moved from %s to %s. $status = %s',
    $file_temp,
    $file_path1,
    $status ? 'true' : 'false'
);

By the way, you do not need to add !important to inline style tags, as inline CSS always overrides existing CSS rules.

minitauros 151 Junior Poster Featured Poster

you may remove ads by installing AdblockPlus; Id not change anything on main page - its ok....

-----

And it got worse and worse and worse each day. Less traffic also means less advertising revenue, and it got so bad that I've had to spend a huge portion of my savings just being able to afford our hosting bills to keep the site up over the past 2 years.

This is why I don't use things like Adblock. People hosting great sites don't have to do that for free, how could they? At least give them a fair chance of getting some income to play even (at the least).

minitauros 151 Junior Poster Featured Poster

Nice one! I think I've learned pretty much all I know about HTML and CSS using that website.

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

Could you formulate that as a full-scentence question? Maybe some context?

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

It's cool that you are constantly developing Daniweb, but I feel that it's time to mention some things that I feel are missing since the last overhaul:

  1. Can't easily jump to subforums (like "PHP") any more. This isn't really a problem, because I used to just open the "Web development" section anyway, but I think it would be nice to include some tag filtering at the top of a forum now (or maybe in a fixed sidebar).
  2. Can't see who posted the last reply to a discussion. Usually when I see/saw someone of whom I know has knowledge about a subject reply last to a thread, I knew my help probably wasn't really needed there. Now I need to open the dicussion and find the last post to see what is going on.
  3. Too much spacing. There is just so much spacing right now that I don't really see any coherence between what information is related to what other information. Need more borders or clear section separtors. This applies at least to board overviews & discussions.
  4. What is that status bar doing at the top of a discussion (with the x views, 1 reply, etc.)? That is not information I need when I open a discussion. It is nice information but to place it so overly present at the top of the page might be a bit too much. I want to get down to business fast. See the question, see the first reply/replies, see if I can help. It …
joshl_1995 commented: So true! +0
dtpp commented: true; +1 +0
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

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

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

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

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

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

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

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

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

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

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

You should checkout the DateTime class.

Example:

<?php
$date_1 = new DateTime;
$date_2 = new DateTime;

$date_1->setDate(2015, 02, 01);
$date_1->setTime(0, 0, 0);

$date_2->setDate(2015, 02, 05);
$date_2->setTime(0, 0, 0);

$diff = $date_1->diff($date_2);
echo '$diff: ' . $diff->format('%d days') . '<br>';

// OR:
$date_1->add(new DateTimeInterval('P1Y'); // Adds 1 year to $date_1, check out the DateTimeInterval class.
echo '$date_1 is now: ' . $date_1->format('Y-m-d H:i:s') . '<br>';
minitauros 151 Junior Poster Featured Poster

Yes. A larger screen will cost more resources to render. Working with a 1920 pixel wide website on a mobile phone isn't something most people want - you'd have to scroll all the time to find the content you want to see.

Next, if you have a slow internet connection and need to download large Javascript, CSS and image resources, a website will take longer to load. Also if your phone is slow, loading more resources and keeping them in memory will use up more of the available resources.

So yes, it's both the size of the resources and the complexity of the actions they execute. And maybe more, but this is what I know.

minitauros 151 Junior Poster Featured Poster

Oh yeah I wasn't trying to say anything bad about your code, I was just really wondering if it would matter uppercasing or lowercasing the whole string before converting it :).

diafol commented: no worries +15
minitauros 151 Junior Poster Featured Poster

I mean the size of resources like CSS, Javascript, etc., and if they're optimized to work as fast as possible.

minitauros 151 Junior Poster Featured Poster

It's also the amount of resources that need to be loaded and the complexity of the display. The larger the view that needs to be displayed, the slower it gets. The more content that needs to be downloaded, the slower it gets.

At least, for as far as my knowledge goes.

minitauros 151 Junior Poster Featured Poster

Well, have you checked line 22 in C:\xampp\htdocs\sandbox\config.php? It might contain an error :p.

almostbob commented: :) Kudos +13
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

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

What JorgeM says, plus: my best guess is that it has something to do with the contents of $message. Have you tried omitting $message from your CSV to see if styling still comes through?

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

First thing I see is that your code is a bit.. unexpected:

Your code:

if(isset($_SESSION['user'])== ' '){
    header('location:index.php');
    exit();
}

Should be:

if(!empty($_SESSION['user'])){
    header('location:index.php');
    exit();
}

as isset() returns a true/false value, and not a string like " " (to which you are comparing it now). I suspect that you are checking for the presence of a value in $_SESSION['user'] here, which is why it should be !empty() instead of isset() (isset() is ok, too, but I think you will want to use empty() here. Check the PHP manual for the differences or ask ^^).

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

God damnit I was just getting used to Windows 8, and now they're going to bake scrambled eggs with it to make yet another new interface and who knows what. I actually kinda like Windows 8.

minitauros 151 Junior Poster Featured Poster

Doesn't the Javascript version require two http requests to be made (the post request and then the reload) versus only one when submitting a form right away?

cereal commented: also +13
minitauros 151 Junior Poster Featured Poster

Solved it, I got kinda lost in the bunch of triggers I was creating, and apparently in all the confusion I accidentally changed a trigger to BEFORE delete instead of AFTER delete. My bad!

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

Your script should include something like this:

var number_of_timeouts_executed = 0;

// (Your decrement function:)
function decrement() {

    // If 10 or more timeouts have already been excuted, it's been 10 seconds or more. 
    // Don't execute this function again.
    if(number_of_timeouts_executed >= 10)
        return false;

    number_of_timeouts_executed++;

    // (Your timeout:)
    setTimeout();
}
minitauros 151 Junior Poster Featured Poster

You could add a counter that counts how many times the function has been executed. If it reaches 10, you could prevent the timeout from being set again. I hope that's clear enough :).

minitauros 151 Junior Poster Featured Poster

If you're paying for hosting and if you don't have access to your own MySQL config files, I think you should contact your hosting company and ask them for help. Most solutions that I find on Google (just copy/paste your error into the Google search bar and you'll find plenty) talk about modifying config files.

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.

minitauros 151 Junior Poster Featured Poster

What is it that you want to do, exactly? If you need to "refresh" the content of a div, doesn't that mean you need to check if new data is available?

Or do you just want to load new, already known data into a div after a specific amount of time?

minitauros 151 Junior Poster Featured Poster

I guess that the problem is that you are trying to display XML as XML in an HTML document.

It works like this: Your HTML document has already told your browser it's an HTML document. Therefore your browser will treat your document as an HTML document. If you want the XML to be displayed as how a plain XML file would be displayed if you'd open it with your browser, you need to create a whole new browser window and tell that window that it is an XML - not an HTML - file it should display, and then output the XML.

As M.Qawas Aslam says, using an iframe might do the trick. If that doesn't work, I suggest you open a whole new tab or browser window to display the XML. Or, alternatively, you could search for options to display XML as XML without opening a new window.

M.Waqas Aslam commented: Thanks for explanation :) +7