forTheDogs Posted September 4, 2007 Share Posted September 4, 2007 Greetings to all!!! I am now working on the final glitches on my Labrador database. The first one is an AJAX problem - any AJAX experts out there!! I have a field for the sire that uses a lookup wizard to filter all the names of the sires in the database. It does that part fine - as you type in the name, it brings up the appropriate names. The problem is that very often it will not let one click on the name on the list to fill the field. The box becomes outlined in red and all one can do is see if the sire is there. You cannot add the sire just by typing in his name - whether he is already there or not. The second glitch is with the same field - sort of. Once the sire's name is enteded [if one is lucky enough to get that far] I am wanting to find that name in the list of Labradors and get the ID for him and enter it into the SireID field. Here is what I have so far as an event that is to run before the record is added: "global $conn,$strPedigrees; $str = "select ID from ".$strPedigrees." where RegName='".mysql_escape_string($values["Sire"])."'"; $rs = db_query($str,$conn); if ($data = db_fetch_array($rs)) $values["SireID"] = $data["ID"]; return true;" and here is the error message I get [note that the dog name in it is in fact the sire I was trying to add]: "Technical information Error type 256 Error description 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 'where RegName='Sandylands Gadabout'' at line 1 URL fortheloveoflabradors.com/labradors/Pedigrees_add.php? Error file /homepages/33/d208885282/htdocs/labradors/labradors/include/dbconnection.php Error line 26 SQL query insert into `Pedigrees` Solution This is a general error. It occurs when thereis an error in event code or in SQL." Help with either would be SO Appreciated!!! Quote Link to comment https://forums.phpfreaks.com/topic/67967-solved-dog-pedigree-2-new-problems-with-add-dog-form/ Share on other sites More sharing options...
Barand Posted September 4, 2007 Share Posted September 4, 2007 Does $strPedigrees have a valid value? Quote Link to comment https://forums.phpfreaks.com/topic/67967-solved-dog-pedigree-2-new-problems-with-add-dog-form/#findComment-341681 Share on other sites More sharing options...
forTheDogs Posted September 5, 2007 Author Share Posted September 5, 2007 Hi! I am assuming it does. Pedigrees is the name of the table - does that seem appropriate? I must admit I did not understand why the $str was in front of it this time but I figured they must know [the folks that created the program that generates the database tables for me]. They seem to be a bit stumped on why it is not working. Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/67967-solved-dog-pedigree-2-new-problems-with-add-dog-form/#findComment-342328 Share on other sites More sharing options...
Barand Posted September 5, 2007 Share Posted September 5, 2007 $str = "select ID from ".$strPedigrees." where RegName='".mysql_escape_string($values["Sire"])."'"; echo $str; // what does this give? Quote Link to comment https://forums.phpfreaks.com/topic/67967-solved-dog-pedigree-2-new-problems-with-add-dog-form/#findComment-342337 Share on other sites More sharing options...
forTheDogs Posted September 5, 2007 Author Share Posted September 5, 2007 Hi Again! .select ID from where RegName='Abbeystead Herons Court' This is the result of echo string. Note the table name is missing so I added it as plain ole Pedigrees and this is the new error message: Technical information Error type 8 Error description Use of undefined constant Pedigrees - assumed 'Pedigrees' URL fortheloveoflabradors.com/labradors/Pedigrees_add.php? Error file /homepages/33/d208885282/htdocs/labradors/labradors/include/Pedigrees_events.php Error line 1544 SQL query insert into `Pedigrees` I should have thought to do the echo myself!! Thanks - I will remember this next time! Quote Link to comment https://forums.phpfreaks.com/topic/67967-solved-dog-pedigree-2-new-problems-with-add-dog-form/#findComment-342529 Share on other sites More sharing options...
forTheDogs Posted September 6, 2007 Author Share Posted September 6, 2007 OMG!! I tried this global $conn; $str = "select ID from Pedigrees where RegName='".mysql_escape_string($values["Sire"])."'"; echo $str; $rs = db_query($str,$conn); if ($data = db_fetch_array($rs)) $values["SireID"] = $data["ID"]; return true; AND IT WORKED!!!!! You are amazing!!! One down and only one more to go. I suspect the last one is going to be a toughy though!!! Quote Link to comment https://forums.phpfreaks.com/topic/67967-solved-dog-pedigree-2-new-problems-with-add-dog-form/#findComment-342538 Share on other sites More sharing options...
Barand Posted September 6, 2007 Share Posted September 6, 2007 If you look at the AJAX link in my sig you'll see the sample application does an incremental search similar to the one you described. Enter 'A' Displays Amsterdam, Andorra, Antwerp Now add "N" so you have "An" and it displays Andorra, Antwerp Quote Link to comment https://forums.phpfreaks.com/topic/67967-solved-dog-pedigree-2-new-problems-with-add-dog-form/#findComment-342570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.