I didn’t do much investigating, but here’s another data point. When I open the link, it appears to load the page completely before attempting to load something and then crashing. I saw your recent discussion of loading css for mobile via js. Maybe it’s the js and not the css that’s causing the problem?

It looks like you're trying to mix JS with PHP here. You need to add some code to the ajax success function to do something with the result. From the code you posted, I'm not sure you're actually getting the result you want. But if you are, this code should help you out.

In the index.php file, add an id to the div that contains <?php echo $_POST["dataid"];?>. Let's say you make the id id="resultDiv".

Then in the ajax success function, add this line $("#resultDIV").html(dataid). This will change the contents of the div to the ajax results.

Kathy, when you submit via post, the values are being sent as strings. So in File 2, change the line if($cityID == 0) to if($cityID == "0"). When testing code like this, I would recommend changing the redirect to a printout of the posted value. That method has helped me track down many problems. If you do that before changing the line, you'll see that no matter what value is passed, it's evaluating as true even though the posted value is clearly not 0. According to the php documentation on comparison types, this comparison ("string" == 0) will cast the string as an integer, which will always be 0 unless the string starts with a number. Hope that helps, comparisons can be confusing.

Regarding your first question. Do you have the column length set to 1? I'm not a database expert, and I haven't used Double as a column type before. I always use Decimal, but from what I've read, Double and Decimal are virtually the same except for precision. So the only reason I can think for it to be setting to 0 is if you have the column limited to one digit.

As for your second question, this line of code $Id=$_GET['Id']; isn't capturing anything because you haven't set $_GET['Id']. You need to pass that in the url with your javascript code.

Also, I noticed that you aren't escaping or filtering any of the values that you are capturing with the GET request. This is a very, very important thing to do! As your code stands now, it is vulnerable to attacks. You can read about the mysql_real_escape_string function here.. Take note, however, that using mysql_query() and mysql_real_escape_string() are removed in PHP 7.0.0. You should begin to familiarize yourself with MySQLi or PDO_MySQL. Read the warning when you follow the link above.

Because you are including idadi.php along with your form, it would reset the value to "0" if the page is loaded without any $_GET data sent. I'm not an expert in writing AJAX requests without using a framework, but it looks like what you have might be loading the form page. If you want to leave it this way, then you would need to catch (in idadi.php) the instance where you haven't submitted any form data. Maybe something like if(isset($_GET['q'])){...update database...}. You could also choose to only include idadi.php if $_GET data has been sent.

When I've done things of this nature, I use an ajax request to only open the file doing the database update (idadi.php in your case) and not include it in the form page. But I would still recommend checking to see if there is any $_GET data sent.

A-ha, I had thought that there must be a way to do this! I hadn't thought to create an new ID column in the SELECT statement and use UNION ALL. This is much cleaner than trying to sort and combine several separate queries with PHP. Thank you pritaeas!

I do appreciate your help! I'm not too proficient with MySQL, so I was wondering if this could be done in a single query. It looks like it can't be done though, so I'll just write several queries and combine/sort the results in the rest of my PHP code.

Well, what I need is the results that match ICAO_Ident sorted and shown, then Location_Identifier sorted and shown, etc. I sort the results by ICAO_Ident.

For the first result where ICAO_Ident LIKE '%$fix%', ICAO_Ident might be "KEKM", so I would want it shown at the top. But other matches may have ICAO_Ident as say "KABC", so if I sort, then the wrong match would be shown first.

Possible to do that in one query?

Consider the following query:

//$fix and $limit are dynamic values
$query="SELECT ICAO_Ident AS ID, Location_Identifier AS LocID, Official_Facility_Name AS Name, Landing_Facility_Type AS AptType, Associated_State_Post_Office_Code AS State, Associated_City_Name AS City FROM APT WHERE `Location_Identifier` LIKE '%$fix%' OR `ICAO_Ident` LIKE '%$fix%' OR `Official_Facility_Name` LIKE '%$fix%' OR `Associated_City_Name` LIKE '%$fix%' ORDER BY `ICAO_Ident` LIMIT ".$limit."";

I would like to list the results that matched ICAO_Ident first, then Location_Identifier, then Official_Facility_Name, then Associated_City_Name. I've tried using sort, but sort alone doesn't give priority to a given column. I could use multiple queries, but I'd like to do it in one. Is there a way to do this in a single query?

It appears that the action is not set on your page. It's just <form method="POST" action>. When setting the page to <form method="POST" action="navigation.php">, the browser loads only navigation.php as expected, which appears to be your navigation sidebar. It also throws a Call to undefined function getuserdata() error, which I would guess is because you normally include that function in another section of your page. I suggest using an ajax call (documentation here if you need it) to submit your form data to a php page dedicated to handling your database entries. Have the php page return a json response to the ajax call so that you can alert the user to success/failure of the script.

Instead of setting search.php as your source, you will need to set your source as a function with an ajax call to search.php. See the jQuery UI documentation on how to do this here

Thanks for the suggestion Borzoi! My web host provides my email hosting as well, so I assume they are on the same server. Unfortunately, I don't have access to mail logs from my web host. But maybe they will be able to look at them for me.

So I've got a php script that emails me a daily database backup via cron. The script will either output success or failure upon mail->send(), and it always succeeds. However, no email ever is delived if the domain name is the same (i.e. www.example.com and myself@example.com), but if I send to another domain such as myself@gmail.com then the script works fine. Obviously, a solution would be to just email myself@gmail.com, but I'm trying to understand why I can't send emails to @example.com.

Note: It will send emails to @example.com when run from the browser. What could suppress emails to @example.com from cron and not the browser?

Oh, thank you so much! I had searched high and low for an answer and tried everything I could think of. This finally worked!

Hi, I'm having trouble figuring out how to prevent the default tab action when using jquery ui catcomplete. It works perfectly until I add the catcomplete widget code. I'm using the catcomplete widget code found on jquery ui.com:

$.widget( "custom.catcomplete", $.ui.autocomplete, {
    _renderMenu: function( ul, items ) {
      var that = this,
        currentCategory = "";
      $.each( items, function( index, item ) {
        if ( item.category != currentCategory ) {
          ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
          currentCategory = item.category;
        that._renderItemData( ul, item );

and again I'm using the code on the jquery ui website to prevent the default tab action:

.bind( "keydown", function( event ) {
    if ( event.keyCode === $.ui.keyCode.TAB &&
        $( this ).data( "ui-autocomplete" ).menu.active ) {

However, I get the following error: cannot read property 'menu' of undefined. Any thoughts on why the menu property isn't being defined?

Thanks for the help! This is what I ended up doing:


That results in an array with the desired query as the value. Then I can run another query with the array value.

I know how to do that with a separate query and php. Is there a way to do it all in one mysql query?

I'm trying to sum all numeric fields individually. I won't always know the field names, otherwise I could manually construct the query SELECT SUM(Field1) as Field1, SUM(Field2) as Field2...etc FROM myTable Is there a way to construct this on the fly in mysql? I'm thinking there's probably a way to incorporate SELECT COLUMN_NAME FROM information_schema WHERE TABLE_NAME=myTableName AND DATA_TYPE IN('tinyint','decimal'), but I'm not sure how. Thanks!

I'm having a problem with a MYSQL Join accross three tables. I'm new to MYSQL Join functions, and can't quite figure out how to write the code. My current code is horribly innefficient and does not implement explicit joins, which I believe is much of the problem. Here it is(in php):

mysql_query("Select Airports.*, Regions.name AS RegionName, Countries.name AS CountryName, Regions.local_code AS StateCode FROM Airports, Regions, Countries WHERE Airports.ident LIKE '%".$fix."%' AND Regions.iso_region=Airports.iso_region AND Countries.code=Airports.iso_country")

I think this code shows pretty clearly which information I need from the database. Any suggestions on how to write the explicit join would be much appreciated!

Airshow, thank you for adding your input! I had forgotten that I actually do need to allow no input, and your script allows for that. It works perfectly for what I need to do! And thank you also for the detailed description for this JS noob!

Guys, thank you so much for the help! I had to modify it a bit to /^(?:[A-Z]{3}[0-9]{3}, )*[A-Z]{3}[0-9]{3}$/, as I want to accept any input that is [A-Z]{3}[0-9]{3}, not only AAA111. Just to be clear that I understand how this regex is working, ^(?:[A-Z]{3}[0-9]{3}, )* says that there should be a match of, say, ABC123 0 or more times at the very beginning of the string. And [A-Z]{3}[0-9]{3} says that next there should be a match of, say, XYZ789. $ means that there should be nothing after. Am I correct in my understanding of the syntax?

That will only check for a single entry of, say, AAA111 right?. AAA111 is a valid entry, but so is AAA111, AAA112 and ABC123, AAA111, AAA113. I need to check that each item entered as AAA111 is separated by a comma and a space. And it has to end with an AAA111 entry. But I don't know how many entries in the AAA111 format there will be.

Hi I'm working on a form validation script. Up to this point, I've only written very basic regex validations. The input that I'm trying to validate should have entries in the following format AAA111 separated by comma space. So some sample entries are : ABC111 or ABC111, ABC112, ABC113. Here's what I have so far:

            //do something

But this only catches a match at the beginning of the string. Any tips on how to expand the regex?

Actually, I found an easier way. Use distinct. It can be used across several columns. Here's an example I think you may find helpful. http://sqlfiddle.com/#!2/40133/1

Maybe instead of two columns for month/year, use one column with the date formated as whatever month/year format you like, then select unique entries from that column for the unique months.

Hi, I haven't done any work with images in a database, so I'm not much help to you there. As for your second problem, if you want to either enable or disable all of the links based on if the user is logged in, then I would make two separate pages, say links.php and no-links.php, and include links.php if the user is logged in and the other if the user is not logged in.

So when the user logs in, I would set a session cookie, say $_SESSION['logged-in']=yes, but it could be anything you want. Then for your include code, you could have:

    if($_SESSION['logged-in']='yes'){ //check to see if the session variable is set
        include_once('path-to-file/links.php'); //if it is, include the links file
    else {
        include_once('path-to-file/no-links.php'); //else include no-links file

Put the code you have listed in two files - one with links, one without - and put the include script where it was.

First, I'm wondering why you're using frames? If you're wanting to have consistent banner and navigation portions of the page without having to write it into each page, just use php's include_once() statement. You're page (say index.php) may then look something like this:

<div style="width:1000px;margin:auto;border:1px solid black;">
    <div><?php include_once('banner.php'); ?>&nbsp;</div>
    <table style="border-collapse:collapse;">
        <tr><td style="padding:0px;width:100px;border:1px solid black;">&nbsp;</td>
            <td style="padding:0px;width:800px;border:1px solid black;"><?php include_once('home.php');?></td>
            <td style="padding:0px;width:100px;border:1px solid black;"><?php include_once('accounts_page.php');?></td>

Hey guys, thanks so much for the help. I finally figured it out, and I didn't end up using sessions. Here's what I ended up with:

$ID = $_GET['Record'];
$result = mysql_query("SELECT * FROM $logbook WHERE ID='$ID'");
$Rows=mysql_query("SELECT * FROM $logbook WHERE Date='$Date' ORDER BY Date ASC");
if($Num==1){ //If there's only 1 record, get record from next/previous date
    $Next = mysql_fetch_array(mysql_query("SELECT * FROM $logbook WHERE Date>'$Date' ORDER BY Date LIMIT 1"));
    $Prev = mysql_fetch_array(mysql_query("SELECT * FROM $logbook WHERE Date<'$Date' ORDER BY Date DESC LIMIT 1"));
else{ //If there is more than 1, put them in an array and get position of current ID
$i = 0;             //counter so we know where our current record is located
while( $data = mysql_fetch_assoc($Rows) ) {
    $records[] = $data;
    if( $ID == $data['ID'] ) {
        $currentRecordPosition = $i;

//If there is a record in the previous/next array position, get ID from array
//If not, get ID from record with next/previous date

    if( is_array($records[$currentRecordPosition - 1]) ){
        $Prev = $records[$currentRecordPosition - 1];    
    } else { 
        $Prev = mysql_fetch_array(mysql_query("SELECT * FROM $logbook WHERE Date<'$Date' ORDER BY Date DESC, ID DESC LIMIT 1"));

    if( is_array($records[$currentRecordPosition + 1]) ){
        $Next = $records[$currentRecordPosition + 1];    
    } else {
        $Next = mysql_fetch_array(mysql_query("SELECT * FROM $logbook WHERE Date>'$Date' ORDER BY Date, ID LIMIT 1"));

Hope this helps somebody with a similar problem!

seslie commented: Thanks for Sharing +1

I'll try using a session variable to keep track of which duplicate dates I've already looked at. I'll post what I find.

I'm having trouble grasping how to implement your suggestion. And couldn't iterating with php result in a lot of queries and unnecessary server load?