Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. Change this $result = mysql_query("SELECT * FROM `ordersmaster` JOIN `orders` ON `orders.orderno` = `ordersmaster.orderno` JOIN `books` ON `books.ncode` = `orders.book` WHERE `member` = '$user' AND `status` = 'S' ORDER BY `ordersmaster.orderno` ASC "); To this: $query = "SELECT * FROM `ordersmaster` JOIN `orders` ON `orders.orderno` = `ordersmaster.orderno` JOIN `books` ON `books.ncode` = `orders.book` WHERE `member` = '$user' AND `status` = 'S' ORDER BY `ordersmaster.orderno` ASC "; $result = mysql_query($query) or die (mysql_error()."<br><br>$query"); It won't fix the problem, but it will give you more details about the problem.
  2. There probably is some syntax error in my query, I just don't have your database and environment to test against. But, here is an explanation of how youwould display the results. Your results might look like this (assuming sort by member and then by order): ORDERNO | MEMBER | BOOK ---------------------------------------------------- 218668 | Bob | Tom Sawyer 218668 | Bob | Moby Dick 384698 | Bob | Catcher in the Rye 156768 | Jane | The Prophecy 156768 | Jane | Astrology and You 156768 | Jane | Where's Waldo 265978 | Doug | PHP for Dummies So, Bob has two orders and Jane and Doug have one order each, some with multiple books. Here is one way to display the records in a logical format: while ($record = mysql_fetch_assoc($result)) { //Display the member title if ($current_member!=$record['member']) { $current_member = $record['member']; echo "<br /><b>{$current_member}</b>\n"; } //Display the order title if ($current_order!=$record['orderno']) { $current_order = $record['orderno']; echo "<br />Order: {$current_order}<br />\n"; } //Display the book echo " - {$record['book']}<br />"; } The result would look like this: Bob Order: 218668 - Tom Sawyer - Moby Dick Order: 384698 - Catcher in the Rye Jane Order: 218668 - The Prophecy - Astrology and You - Where's Waldo Doug Order: 265978 - PHP for Dummies
  3. i think it's easier, but i just want to make sure that i dont mess up codes, it's already a great thing for me to do some working scripts, i think i'll be using those when i'm really tired of typing codes, but for now, i'll settle with [' '] I beleive he's referring to this bit of code $sql2 = "SELECT * FROM `my_db` WHERE `expschool`<='".$_POST['expschool']."' AND `status`='1'"; Instead of "exiting" the quotes for the POST value, this could have been done: $sql2 = "SELECT * FROM `my_db` WHERE `expschool`<='{$_POST['expschool']}' AND `status`='1'"; In fact, you can put {} around any variable within a double quoted string and the {} are stripped out of the result. I do agree that it makes it much more readable when decyphering the variables within a string.
  4. Are you sure you mean "nested" forms where one form is inside another form? If you mean separate forms (as genericnumber1 suggests, then you just need separate forms). But, I have never heard of nested forms. I did a quick test where a form was inside another form. I suppose you are expecting if the inner form is submitted that only the inner form data is sent. Whereas if the outer form is submitted then both forms' data is sent. But, my tests showed that all the data from both forms is always sent and in some cases some fields were not sent based upon the layout of the two forms. Not sure what you are trying to accomplish here. More details please.
  5. A Select list cannot be relied upon for validation. A person can "POST" data to your site without using your form(s). Anyone with enough knowledge to perform SQL injection could easily create a copy of your form and modify it to allow any values they want, and then post that data to your site. Never trust any data coming from the user.
  6. The backquotes should be fine. If the expschool and status are numeric fields you can try removing the single quotes from the seach values (as Maq did for the status, but not the expschool). $exp_school = mysql_real_escape_string(trim($_POST['expschool'])); $sql2 = "SELECT * FROM my_db WHERE expschool <= $exp_school AND status = 1"; Also, have you validated the value for $exp_school? You should, at a minimum, use mysql_real_escape_string() on that value before running a query on it - otherwise you are opening a hugh hole for SQL Injection.
  7. Well the error tells you that the query failed. You should have some error handling on your queries. But, I alwasy suggest that queries be created as string variables so you can echo the entire query to the page when there is an error. In this case I suspect that $itemcode does not have the value you expect is has. You could try this: include('../CMS/global.inc.php'); $query = "SELECT * FROM `books` where `ncode` = '$itemcode'"; $result3 = mysql_query($query) or die ("Error:<br />".mysql_error()."<br />Query:<br />$query"); $row3 = mysql_fetch_array($result3); However, a more important issue, in my opinion, is the use of looping, nested queries. It is terribly inneficient and a huge overhead on resources. It also doesn't take advatage of the whole purpose of relational databases. You can get ALL the data you need with a single query by joining tables. This should be correct, but I don't have full information on your structure to be 100% positive. SELECT * FROM `ordersmaster` JOIN `orders` ON `orders.orderno` = `ordersmaster.orderno` JOIN `books` ON `books.ncode` = `orders.book` WHERE `member` = '$user' AND `status` = 'S' ORDER BY `ordersmaster.orderno` ASC
  8. I would also pass the field ID to the function instead of hard codsing the field intot he function to make it more flexible. The script also needs to get the text before and after the selected text to do what you want. This corrects that - however selectionStart and selectionEnd do not work in IE. <html> <head> <script type="text/javascript"> function UBBCode(fieldID, UBB) { fieldObj = document.getElementById(fieldID); var BEFORE = (fieldObj.value).substring(0, fieldObj.selectionStart); var SELECT = (fieldObj.value).substring(fieldObj.selectionStart, fieldObj.selectionEnd); var AFTER = (fieldObj.value).substring(fieldObj.selectionEnd); fieldObj.value = BEFORE + '['+UBB+']' + SELECT + '[/'+UBB+']' + AFTER; fieldObj.focus(); return; } </script> </head> <body> <textarea id="tekst"></textarea> <button onclick="UBBCode('tekst', 'B')";>TEST</button> </body> </html>
  9. What is/is not happening compared to what you want to happen? You state you want a list of products, but it appears the query is only pulling the categories. Although I see what appears to be an error in that. There are strait, single quotes around the field name in the ORDER BY parameter. I'm pretty sure it should be using the slanted quotes. $query = "SELECT * FROM `category` ORDER BY `CAT` ASC";
  10. This should return all the rows where all 9 fields have values SELECT * FROM members2 WHERE username = '$username' AND game = '$game' AND ampiece1 NOT NULL AND ampiece2 NOT NULL AND ampiece3 NOT NULL AND ampiece4 NOT NULL AND ampiece5 NOT NULL AND ampiece6 NOT NULL AND ampiece7 NOT NULL AND ampiece8 NOT NULL AND ampiece9 NOT NULL
  11. The short answer is no, the long answer is yes. You can't do it directly. You would need a service to translate the HTML code into something that can be used for PDF creation - whether you are creating through PHP or even PostScript (the native language for PDF creation). You could build your own interpreter, but it would be time consuming - consider the fact that not every browser renders a page exactly the same. There are plenty of free utilities that will already provide this capability, such as http://html2pdf.seven49.net/Web/ http://www.activepdf.com/products/serverproducts/docconverter/overview.cfm http://www.htm2pdf.co.uk/ http://www.digitaljunkies.ca/dompdf/
  12. Simply add a "break" within the last while loop: $path = 'photos/'; if($_SERVER['QUERY_STRING'] == 'albums') { $listDirectories = true; if(is_dir($path)) { $dir = opendir($path); while(false !== ($file = readdir($dir))) { $type = filetype($path ."/". $file); if($file != "." && $file != ".." && $file != "Thumbs.db" && $listDirectories && $type == "dir") { $list_dir[] = $file; } } } closedir($dir); foreach($list_dir as $subdir) { echo $subdir.'<br />'; if ($handle = opendir($path.$subdir)) { while (false !== ($files = readdir($handle))) { if ($files != "." && $files != "Thumbs.db" && $files != "..") { echo $files.'<br />'; break; } } echo '<br />'; closedir($handle); } } }
  13. Not sure what you mean by that. Are you wanting to grab the two variables as a concatenated string: $combined = $_GET['action'] . $_GET['id']; Although that would not be advised as you should validate those variables first. You could also use implode() on the $_GET var to combine ALL the GET vars, but again, not very safe in my opinion.
  14. According to your code the value of 'bus' will only get incremented if the innerHTML value of one of the divs in the loop exactly equals bus. But, it looks like you may be populating those divs with something like 'BUS1', and 'BUS1' does not equal 1. Have you validated the values reurned in the array of divs?
  15. Have you tried contacting the author of the script you are using? He may have updated it since 2005. It's going to be pretty difficult for anyone to try and determine the problem when we have no idea what documents it works for and which ones it doesn't. One guess would be that the script can only extract from PDFs saved in certain versions. The script was created back in 2005. It is very possible that the format for new versions of PDFs has changes such that the script does not work on the newer versions. UPDATE: According to this page, the current version is 3.2, last updated on 7-17-2007: http://webscripts.softpedia.com/script/Development-Scripts-js/PDF2TXT-30100.html
  16. Not sure I follow your statement "how do i check it without writing the form twice". I typically have all my forms POST back to themselves. If validation fails I can reshow the form with the POSTED values that were valid and the others blank. If validatin passes I will either process the data on the same page or save the posted data to session variables and redirect to the processing page. Here's an example: //Create array of state abbr list $query = "SELECT * FROM tbl_name"; $result = mysql_query($query)or die(mysql_error()); while($record = mysql_fetch_object($result)) { $state_list[] = $row->state_abbr } $valid = false; //If form submitted validate data if (isset($_POST['state_submit'])) { $valid = (in_array($_POST['state_submit'], $state_list)); } if ($valid) { //Process the data //Redirect to confirmation page header('Location: http://www.mysite.com/confirm.php'); } else { //Show the form echo "<p>Select your state</p>\n"; echo "<form action=\"file.php?action=make\" method=\"post\">\n"; echo "<select name=\"state\" onChange=\"this.form.submit();\">\n"; echo "<option value=\"\"></option>\n"; foreach ($state_list as $state_abbr) { echo "<option value=\"$state_abbr\">$state_abbr</option>\n"; } echo "</select>\n"; echo "<input type=\"submit\" value=\"Submit\" name=\"state_submit\" />\n"; echo "</form>\n"; }
  17. It's because of the manner in which you are populating the innerHTML code. By continuously updating on each line there is no complete table when it is first populated. The browser is gettign confused and doesn't go back to the initial TABLE tag to determine how everything is going to be displayed. Try this: for (var x = 1; x <= num; x++) { var htmlOutput = document.getElementById('extracards').innerHTML; htmlOutput += '<table cellpadding="5" cellspacing="0" border="0" align="center">'; htmlOutput += '<tr>'; htmlOutput += '<td><b>Choose card</b></td>'; htmlOutput += '<td style="padding-right: 20px;">'; htmlOutput += '<select name="cardtype"><option value="V">Visa®</option><option value="M">MasterCard®</option></select>'; htmlOutput += '</td>'; htmlOutput += '<td><b>Security code</b></td>'; htmlOutput += '<td style="padding-right: 20px;"><input name="cardcode" type="text" size="10"></td>'; htmlOutput += '<td><b>Expiry date</b></td>'; htmlOutput += '<td style="padding-right: 20px;"><input name="cardexpiry" type="text" size="10"></td>'; htmlOutput += '<td><b>Amount to charge</b></td>'; htmlOutput += '<td><input name="cardcharge" type="text" size="10"></td>'; htmlOutput += '</tr>'; htmlOutput += '</table>'; document.getElementById('extracards').innerHTML = htmlOutput; }
  18. What do you mean by "signal stregth"? I doubt you can accomplish this with only JavaScript. You are going to need some server-side code to do the connection and get the "signal strength" data - if that is even possible. You could use JavaScript in combination with that to have the data updated on the page dynamically without having to refresh the page (i.e. AJAX).
  19. Give this a try <?php /* When this function is called, all mp3 files in the multimedia/servicearchives are listed and linked to as downloadable. Params: None **/ function CreateM3UFile($mp3Name, $m3uName, $dirToCreate){ /* When this function is called, m3u files are created for the mp3. Params: $mp3Name as the file name of the mp3 and $mpuName as the file of the m3u and $dirToCreate as the dir where the m3u file will be created. **/ $myFile = $m3uName; $fh = fopen($dirToCreate . $myFile, 'w') or die("can't open file"); $stringData = "http://www.spiritaliveon65.org/multimedia/servicearchives/" . $mp3Name; fwrite($fh, $stringData); fclose($fh); } function sortMP3s($a, $b) { if ($a['date_sort'] == $b['date_sort']) { return 0; } return ($a['date_sort'] < $b['date_sort']) ? -1 : 1; } function ListServices($dirPath){ /* When this function is called, all mp3 service files are listed in a specified directory. Params: $dirPath as the path of the services **/ $dh = opendir($dirPath); $mp3_list = array(); //Read all mp3 files and data into an array while (false !== ($file = readdir($dh))) { //Don't list subdirectories if (!is_dir("$dirpath/$file")) { $fileParts = explode(".",$file); if ($fileParts[1] == "mp3") { $dateParts = explode("-",$fileParts[0]); $index = count($mp3_list); $mp3_list[$index]['date_sort'] = $dateParts[0].$dateParts[1].$dateParts[2]; $mp3_list[$index]['year'] = $dateParts[0]; $mp3_list[$index]['month'] = str_pad($dateParts[1], 2, '0'); $mp3_list[$index]['day'] = str_pad($dateParts[2], 2, '0'); $mp3_list[$index]['dateTitle'] = $dateParts[3]; $mp3_list[$index]['file'] = $file; } } } //Sort the array usort($mp3_list, 'sortMP3s'); //Process/display the array foreach ($mp3_list as $mp3) { $m3uName = mktime() . "-" . rand(1, 3000) . ".m3u"; $itemTitle = date("F j, Y", mktime(0, 0, 0, $mp3['month'], $mp3['day'], $mp3['year'])) . ": " . $mp3['dateTitle'] . ": "; echo $itemTitle . "[<a href='http://www.spiritaliveon65.org/multimedia/servicearchives/streaming/" . $m3uName . "'>Stream</a>]<br>"; CreateM3UFile($file, $m3uName, $dirPath . "/streaming/"); } closedir($dh); } ?>
  20. You have two different functions with the same name "validate_form". Each function needs a unique name.
  21. Nightslyr's solution is much more elegant. But, to answer your question directly (to prevent similar errors in the future) the problem in your code was related to the use of quote marks. You used a double quote mark to open the trigger event, and then used a double quote mark within the getElementById() function. onmouseover="document.getElementById("blockTR").src = 'img/category_music.jpg';" When the browser tries to read that it sees this onmouseover="document.getElementById(" It should work with this (but I'd stick with the code nightslyr provided) onmouseover="document.getElementById('blockTR').src = 'img/category_music.jpg';"
  22. OK, I think I am starting to understand. I ran the code above and see the same results in IE7 and FF3. Don't have access to IE at the moment. I see the same results in IE6 and FF3. If I select a value in the first field text is displayed above it. But, when I use left/right arrow keys the field is reset to the 0 index and the text remains. It would really help if you list the steps you would take and the resulting action you want to occur. But, I think I'm starting to understand. Should only 1 select field have a value and no others? I think adding the keydown event to the body and using a global variable to track the current field will run into problems as well. Try this: <html> <head> <style type="text/css"> select { width: 100px } </style> <script language="javascript"> function processSel(fieldObj) { if(fieldObj.selectedIndex==0) { var resultHTML = '.'; } else { var resultHTML = 'ID: ' + fieldObj.id + ' VALUE: ' + fieldObj.options[fieldObj.selectedIndex].value; } divID = 'res' + fieldObj.id.substr(4); document.getElementById(divID).innerHTML = resultHTML; return; } function blurThis(fieldObj) { fieldObj.selectedIndex = 0; processSel(fieldObj); return; } function keyB(evt, fieldObj) { try { if (evt.keyCode==37 || evt.keyCode==39) { var index = parseInt(fieldObj.id.substr(4)); index = (evt.keyCode==37) ? (index-1) : (index+1) ; if (index==0) { index = 4; } if (index==5) { index = 1; } document.getElementById('sel_'+index).focus(); } } catch(e) { alert("oops"); } return; } </script> </head> <body> <div id="res1">.</div> <div id="res2">.</div> <div id="res3">.</div> <div id="res4">.</div> <form name="f" id="f"> <select id="sel_1" size="1" onchange="processSel(this);" onblur="blurThis(this);" onkeydown="keyB(event, this);"> <option value="-- sel1">-- sel1</option> <option value="cmd 1">cmd 1</option> <option value="cmd 2">cmd 2</option> <option value="cmd 3">cmd 3</option> </select> <select id="sel_2" size="1" onchange="processSel(this);" onblur="blurThis(this);" onkeydown="keyB(event, this);"> <option value="-- sel2">-- sel2</option> <option value="cmd 1">cmd 1</option> <option value="cmd 2">cmd 2</option> <option value="cmd 3">cmd 3</option> </select> <select id="sel_3" size="1" onchange="processSel(this);" onblur="blurThis(this);" onkeydown="keyB(event, this);"> <option value="-- sel3">-- sel3</option> <option value="cmd 1">cmd 1</option> <option value="cmd 2">cmd 2</option> <option value="cmd 3">cmd 3</option> </select> <select id="sel_4" size="1" onchange="processSel(this);" onblur="blurThis(this);" onkeydown="keyB(event, this);"> <option value="-- sel4">-- sel4</option> <option value="cmd 1">cmd 1</option> <option value="cmd 2">cmd 2</option> <option value="cmd 3">cmd 3</option> </select> </form> </body> </html>
  23. Actually I misread your response. Your code does uncheck the "child" field when the "parent" is checked. But, it also checks the "child" when the "parent" is unchecked. Not sure if that was what he wanted. But, then again, not enough specifics were given.
  24. He asked to have all the other field unchecked if the particular field was checked. This will do that, as well as disable the fields when unchecked. <html> <head> <script type="text/javascript"> function uncheckAll(uncheckAll_switch) { //Uncheck all boxes if option checked if (uncheckAll_switch) { document.getElementById('check1').checked = false; document.getElementById('check2').checked = false; document.getElementById('check3').checked = false; document.getElementById('check4').checked = false; } //Disable/Enable all the checkboxes document.getElementById('check1').disabled = uncheckAll_switch; document.getElementById('check2').disabled = uncheckAll_switch; document.getElementById('check3').disabled = uncheckAll_switch; document.getElementById('check4').disabled = uncheckAll_switch; return; } </script> </head> <body> <input type="checkbox" name="clear_all" id="clear_all" onclick="uncheckAll(this.checked);"> Check here to uncheck all other boxes <br><br> <input type="checkbox" name="check1" id="check1"> Checkbox 1<br> <input type="checkbox" name="check2" id="check2"> Checkbox 2<br> <input type="checkbox" name="check3" id="check3"> Checkbox 3<br> <input type="checkbox" name="check4" id="check4"> Checkbox 4<br> </body> </html>
  25. Sorry, I posted the wrong code //List out the names for each field $post_fields = array ( 'rm_loc', 'resident', 'patient', 'mrn', 'age', 'race', 'gender', 'pod', 'rcf_date', 'dx', 'meds', 'pmhx', 'problist', 'anticipate', 'antic2', 'antic3', 'antic4', 'todo', 'todo2', 'todo3', 'todo4', 'comments', 'code', 'allergy', 'signoff_status'); //Convert all the 'appropriate' post fields to query parts foreach ($post_fields as $field) { //Get value of current field from POST data $value = mysql_real_escape_string(trim($_POST[$field])); //If some fields include add'l processing/validation include it here switch ($field) { case 'rm_loc': $value = ereg_replace("[^A-Za-z0-9]", "", $value); break; } //Add partial query to array $set_parts[] = "{$field}='{$value}'"; } //Don't know what the purpose is of this - should just use $newdate in the query $rcf_date2 = $newdate; //Create the query (include any SET's not from POST data explicity) $sql = "UPDATE icu SET " . implode(', ', $set_parts) . ", rcf_date2='$rcf_date2' WHERE id_incr = '$id_incr'"; //Run the query echo "<!--" . $sql . "-->"; mysql_query($sql) or die ("Invalid query: " . mysql_error());
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.