Jump to content

sanfly

Members
  • Posts

    344
  • Joined

  • Last visited

Everything posted by sanfly

  1. Hi all I have a script (below) where different things should happen when checkboxes are selected The first thing is that when you click on the "Band" option, a bunch of new options should appear. This works fine. The second is that when you click on the "All Years" option, it should disable the other years. When I click on this I get an error: Now, I cant figure out why im getting this message. I was wondering if it was something to do with the fact that the bandYears[] checkbox array is put into the form using Javascript, rather than "hard coded"? Or is it something else? Can anyone help? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script language="JavaScript"> function getBandOptions(){ if(document.maillist.u_group[4].checked == true){ document.getElementById('bandYear').innerHTML = '<b>Year: </b><br></td><td><input type="checkbox" name="bandYears[]" value="all" style="vertical-align: middle;" onClick="disableYears();"> All years<br><input type="checkbox" name="bandYears[]" value="2007" style="vertical-align: middle;"> 2007<br><input type="checkbox" name="bandYears[]" value="2006" style="vertical-align: middle;"> 2006<br><input type="checkbox" name="bandYears[]" value="2005" style="vertical-align: middle;"> 2005<br>'; document.getElementById('bandCountry').innerHTML = '<b>Country: </b></td><td id="countrySelect">'; document.getElementById('bandRegion').innerHTML = '<b>Region: </b></td><td id="regionSelect"><select name="b_region" disabled><option value="SELECT REGION"></select>'; } else{ document.getElementById('bandYear').innerHTML = ""; document.getElementById('bandCountry').innerHTML = ""; document.getElementById('bandRegion').innerHTML = ""; } } function disableYears(){ arrayLength = document.maillist.bandYears.length; if(document.maillist.bandYears[0].checked == true){ for(i = 1; i < arrayLength; i++){ document.maillist.bandYears[i].disabled = true; } } else{ for(i = 1; i < arrayLength; i++){ document.maillist.bandYears[i].disabled = false; } } } </script> </head> <body> <table align="center" class="mainTable" cellpadding="0" cellspacing="0" border="0"> <tr class="headingTr"><td valign="top"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="440" HEIGHT="200" id="wbotb-map-2007" ALIGN=""><PARAM NAME=movie VALUE="images/wbotb-map-2007.swf"><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><param name="wmode" value="transparent"><EMBED src="images/wbotb-map-2007.swf" quality=high bgcolor=#FFFFFF WIDTH="440" HEIGHT="200" NAME="wbotb-map-2007" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" wmode="transparent"></EMBED></OBJECT></td><td valign="top" align="right"><a href="index.php"><img src="images/2007-header-logo-only-black.jpg" width="340" height="200" border="0" title="WORLD BATTLE OF THE BANDS WEBSITE"></a></td></tr> <tr class="navTr"> <td colspan="2" valign="top"> Menu goes here </td> </tr> <tr> <td colspan="2" class="mainContent" valign="top"> <title>WBOB Mailing List</title> <div class="heading"><img src="images/h_send_group_email.png" alt="SEND GROUP EMAIL" width="235" height="30" border="0" title="SEND GROUP EMAIL"></div><br> <form name="maillist" method="post" action="maillist.php?action=sendmail2"> <table> <tr> <td valign="top" align="right" width="90"><b>User Group: </b></td> <td valign="top" width="180"> <input type="checkbox" name="u_group[]" id="u_group" value="1" style="vertical-align: middle;"> Website Administrator<br> <input type="checkbox" name="u_group[]" id="u_group" value="2" style="vertical-align: middle;"> Administrator<br> <input type="checkbox" name="u_group[]" id="u_group" value="3" style="vertical-align: middle;"> Regional Coordinator<br> <input type="checkbox" name="u_group[]" id="u_group" value="12" style="vertical-align: middle;"> Photographer<br> <input type="checkbox" name="u_group[]" id="u_group" value="6" onclick="getBandOptions();" style="vertical-align: middle;"> Band<br> </td> <td valign="top"> <br><br><br><br><br><br> <table cellspacing="5"> <tr> <td valign="top" id="bandYear"></td> <td valign="top" id="bandCountry"></td> <td valign="top" id="bandRegion"></td> </tr> </table> </td> </tr> <tr> <td colspan="3"><hr></td> </tr> <tr> <td colspan="3"> <hr> <br> <input type="button" onclick="history.back();return false;" value="« CANCEL"> <input type="submit" value="PREVIEW »"> </td> </tr> </table> </form> </td> </tr> <tr> <td class="mainFooter" colspan="2"> <table cellspacing="0" cellpadding="0" width="100%" border="0"> <tr> <td> <a href="contacts.php?action=list" class="footerNav">CONTACT US</a> :: <a href="sitemap.php" class="footerNav">SITE MAP</a> All Content © 2007 World Battle of the Bands Ltd </td> <td align="right"> <a href="http://www.intergalacticrecords.com" target="_blank"><img src="images/igr_logo_60.gif" alt="" width="60" height="60" border="0" style="vertical-align: middle;" title="INTERGALACTIC RECORDS"></a> <a href="http://www.sanfly.com" target="_blank"><img src="images/sanfly-mini-logo.gif" title="SANFLY WEB DESIGN" width="76" height="32" border="0" style="vertical-align: middle;"></a> </td> </tr> </table> </td> </tr> </table> </body> </html>
  2. In the query you have above, you're saying all three fields should not be empty There are two ways I would do it (assuming im understanding you correctly here); option 1 $result = mysql_query("SELECT health_safety2, insurance2, security2 FROM incident_property WHERE id = '$id' && health_safety2 != '' && insurance2 != '' && smt2 != ''") or die(mysql_error()); $num = mysql_num_rows($result); option 2 $num = mysql_result(mysql_query("SELECT COUNT(*) AS NUM FROM incident_property WHERE id = '$id' && health_safety2 != '' && insurance2 != '' && smt2 != ''"), 0); or something along those lines
  3. Thanks for the replies I ended up figuring it out the problem is that IE does not handle the innerHTML of Select tags properly. For some reason it loses the first <option> tag. You can get around it by using java script to add additional options individually, or do what I did and put the whole select tag inside a span tag, and change the inner HTML of that.
  4. I adapted this code for my own use, and found that it worked in Firefox, but not IE It turns out that when you use getElementById in IE, the innerHTML of <select> tags comes back all screwy - it somehow chops out the first <option> tag or something and that, at least for me, was why it wasnt working. You can get around this by using javascript to add the options, but I chose an easier way, and just put my entire <select> drop down in <span> tags, gave that an Id and replaced the whole select drop down rather than just the options. Just another reason why IE sux.....
  5. Can anyone tell me why this would work in Firefox but not IE? document.getElementById('g_region').innerHTML = '<option value="NULL"> SELECT REGION ' + result;
  6. Shouldnt the line in red below be
  7. You will need to post your code
  8. Someone has said to me that when using a form (method = post), that storing data in "hidden" tags ie <input type="hidden" name="myField" value="something"> means that the user can set the value to whatever they like So my questions are: 1. How would they do this 2. How can I stop it 3. Do I have to abandon the hidden values and go with sessions? Thanks in advance
  9. Hi Guys i have an excel file I want to read into a database. I found a tutorial which says to save the file into a xml file, then it basically gets all the data out, and puts it into an array The code seems to be falling over at this line so far: and gives this error: Undefined class name 'domdocument' in /home/myhost/public_html/import.php Ive also tried this which gives this error: Any ideas?
  10. Please dont spam in my thread
  11. I have decided to pass the array as a session instead, but would still be interested in a solution for doing it this way if anyone knows
  12. Hi All Im probably overlooking something simple here, but if someone can point me in the right direction I would really appreciate it. I have a form which people fill in, it takes them to a page where the details are all displayed, and they then click on confirm to verify that these details are correct. I thought the easiest thing to do would be to pass the whole post array through the form on the "confirm" page, then just extract it on the next (processing) page However, when I try print_r on the value I assigned to the post array, it just says "Array". My code is below, what have I done wrong? At the end of the confirm page: <form method="post" action="booking2.php?action=book3"> <input type="hidden" name="postArray" value="<?=$_POST?>"> <input type="hidden" name="confirmed" value="1"> <input type="Button" onclick="history.back(); return false" value="« EDIT DETAILS"> <input type="submit" value="CONFIRM DETAILS »"> </form> And on the next (processing) page: <?// Get posted variables $postArray = $_POST['postArray']; $confirmed = $_POST['confirmed']; print_r($postArray);?>
  13. There are two ways I know of, just plug in the code wherever you want it to go: <?php header("Location: URL GOES HERE"); ?> but I find that never works for me and the way I code, I always get "header already sent" errors so, i use javascript <?php // some php here ?> <script> window.location = "URL GOES HERE"; </script> <?php // some other php here ?> EDIT: Just read more carefully. Put it just after the mail() function, but before the }
  14. You would need to separate the info out into an array So, you could put your data into the text box like this, with each number separated by a comma 4,5,6,7,8,9 Then, when you retrieve the data onto the POST page, put it into an array using explode(). After that you use foreach() to cycle through each value <?php $con = mysql_connect("mysql","database","password") or die('Could not connect: ' . mysql_error()); mysql_select_db("database", $con) OR die(mysql_error()); ?> <form action="<?php $_SERVER['PHP_SELF'] ;?>" method="post"> <span>Enter the ids you want to delete, separate each with a comma.</span> <input type="text" name="id" /> <input type="submit" name="submit" value="submit" /></form> <?php if (isset($_POST['submit'])) { $delete = mysql_real_escape_string($_POST['id']); $array = explode(',', $delete); foreach($array as $value){ $value = trim($value); // to remove any whitespace if you enter spaces in the textbox $query = "DELETE FROM `addid` WHERE `id` = '$value'"; $result = mysql_query($query) or die('Error with query: ' . mysql_error()); if ($result == 0){ echo "Row $value not found. Click back button and try again<br>."; } else{ echo "Row deleted successfully!! To delete another, just click the back button<br>."; } } } ?> This should work but obviously havent tested it, let me know if there are any problems Ive also tidied up your code a little. In the If/else statement after you executed your query, you had two else{} statements. Your second one was unnecessary as you already have the mysql_error() echoed in the die statement. Also, if you have more than one else option, you need to write like this: <? if($something == true){ // do this } elseif($someOtherThing == true){ // do some other thing } else{ // do yet another thing } ?>
  15. Okay, what you need to do here depends on exactly what you want to do. Firstly, so is there a field in your table called 'data'? if so, there are certain resevered words in mysql that you should avoid for table names, and data and add are both included here. If you do insist on using it, you probably need to encase it in backticks wherever you use it in your query, eg: `data` or `add`. That aside, are you wanting to delete the whole row or just reset the `data` field to empty? If you want to delete the whole row, check out the DELETE syntax in the MySQL manual. Your query should be more like this: $query = "DELETE FROM `add` WHERE `data` = '$delete'"; If you want to just set the data field to empty, the you need to do an update, not a delete $query = "UPDATE `add` SET `data` = '' WHERE data = '$delete'"; Also, I would recommend making the code so the query only gets executed if the submit button has been pushed, otherwise it will delete any rows where the data field is empty, eg: <?php if($_POST['submit']){ $delete = mysql_real_escape_string($_POST['data']); $query = "DELETE FROM `add` WHERE `data` = '$delete'"; $result = mysql_query($query) or die('Error with query' . mysql_error()); if (mysql_num_rows($result) == 0){ echo "Row not found. Click back button and try again."; } else { echo "Row deleted successfully!! To delete another, just click the back button."; } } ?> Oh, and there were un-needed { and } in your code
  16. Thats a shame, im interested to know what that syntax is Try this code below. There are some UBBC tags in there I dont know why, but otherwise, does this work? <?php include ('protect.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://www.purl.org/dc"><head><title>PHP ADVANCE USER MANAGEMENT</title> <link rel="stylesheet" href="style.css"> <style type="text/css"> <!-- .style4 {font-size: 10px} .style5 {color: #66FF66} .style6 {font-size: 10px; color: #66FF66; } .style7 {color: #FF9900} .style8 { color: #FFFFFF; font-weight: bold; font-size: 16px; } .style10 {color: #66FF66; font-size: 16px; } --> </style> <body leftmargin="0" topmargin="0" bgcolor="#ffffff" marginheight="0" marginwidth="0" text="#000000"> <div align="center"> <!--top row: main navigation--> <!--UdmComment--> <table width="795" height="0" border="0" cellpadding="0" cellspacing="0"> <tbody><tr bgcolor="#ffffff"> <td width="347" height="0" bgcolor="#0F0F0F"><img src="pics/header.gif" width="347" height="131" /></td> <td width="448" background="pics/header_scatter.JPG" bgcolor="#ffffff"><p align="left" class="attribution style7" style="margin: 0.6em 0em; line-height: 1.2em;"><span class="attribution style7" style="margin: 0.6em 0em; line-height: 1.2em;"><span class="style8">WELCOME</span> <span class="style10"><?php echo $clientname; ?></span></span><span class="style10">,</span> <span class="style4">You are logged in. You can manage your account below. </span></p> <p align="right" class="attribution" style="margin: 0.6em 0em; line-height: 1.2em;"><font face="Arial Black"><span class="style4"><span class="style5"><a href="main.php">[HOME][/url]</span></span></font><span class="style6"> [ <font face="Arial Black"><a href="inbox.php">INBOX[/url] <?php echo $tmsgs; ?></font>] <font face="Arial Black"><a href="compose.php">[COMPOSE] [ [/url]<a href="memberlist.php">MEMBERLIST] [/url]</font></span></p> <p align="right" class="attribution style4 style5" style="margin: 0.6em 0em; line-height: 1.2em;"><font face="Arial Black"><a href="memberlist.php"> [ [/url]<a href="edituser.php">SETTINGS] [ [/url]<a href="uploadpic.php">UPLOAD PIC] [ [/url]<a href="index.php?id=logout">LOGOUT[/url]</font>] </p></td> </tr></tbody> </table> <table width="797" height="167" border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td width="264" valign="top" background="pics/ok_01.gif"> </p> <div> <?php include ('mangatop.php'); ?> </div></td> <!--middle column: main content--> <td width="264" valign="top" background="pics/ok_02.gif"><p> </p> <p> </p> <p> </p></td> <!--right column: navigation--> <td width="263" valign="top" background="pics/ok_03.gif"><p> </p> <!--/UdmComment--></td> <td width="8" valign="top"><img src="pics/ok_04.gif" width="8" height="165" /></td> </tr></tbody> </table> <table border="0" cellpadding="0" cellspacing="0" width="794"> <tbody><tr> <td height="20" colspan="2"> </td> </tr> <tr><td height="1" colspan="2" bgcolor="#ffffff"></td></tr> <tr align="right"> <td width="369" height="93" background="pics/newletter.gif"><div align="left"></div></td> <td width="438" rowspan="3" background="pics/back.jpg"><div align="left"></div></td> </tr> <tr align="right"> <td height="166"><div align="left"><img src="pics/random.gif" width="363" height="218" /></div></td> </tr> <tr align="right"> <td height="114"><div align="left"><img src="pics/adver.gif" width="368" height="114" /></div></td> </tr> <tr><td height="20" colspan="2"><img src="pics/bottom.gif" width="803" height="188" /></td> </tr> </tbody> </table> <p> </p> </div> </body></html>
  17. Why not use addslashes() before storing anything in your database, and stripslashes() when you retrieve it You may also want to check the status of get_magic_quotes PHP Manual
  18. Okay, well whats this stuff here? echo <<<html Ive never used it before, but seen it a couple of times. Are you able to use php functions when using that sort of syntax?
  19. 1. Is the file you are using that code in a .php file? 2. Is php installed correctly? To check this, make a new file called phpinfo.php. inside that file, put the following code <? phpinfo(); ?> Upload the file and run it. Does the page display a whole bunch of info about your php installation?
  20. So is there still a problem? Try <? $query = "SELECT text_id FROM text ORDER BY text_id DESC LIMIT 1"; $result = mysql_query ($query) OR DIE(mysql_error()); $row = mysql_fetch_array($result); echo $row['tid']; ?>
  21. Try speech marks rather than apostrophes. Something to do with absolute values maybe?
  22. I alter my tables all the time, but would recommend backing up your database before you mess with stuff like that, just in case
×
×
  • 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.