Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Cant see why the page being in an iframe will cause any issues. Try some debugging on the delete query: <?php mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); $delete = $_POST['delete'];//unless register_globals is on, you'll need to retreve the variables form the post superglobal array $checkbox = $_POST['checkbox']; ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Cid</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Date</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>City</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['cid']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['cid']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['customer']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['date']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['city']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php // Check if delete button active, start this if(isset($delete)){ for($i=0;$i<$count;$i++){ if($checkbox[$i]){ $sql = "DELETE FROM $tbl_name WHERE cid='$i'"; mysql_query($sql) or die(mysql_error()); echo '<br />SQL: '.$sql; } } echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete.php\">"; } mysql_close(); ?> </table> </form> </td> </tr> You should get a line of code printed for each of the checked boxes showing whats being put into the query.
  2. Try: <?php mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); $delete = $_POST['delete'];//unless register_globals is on, you'll need to retreve the variables form the post superglobal array $checkbox = $_POST['checkbox']; ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Cid</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Date</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>City</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['cid']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['cid']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['customer']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['date']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['city']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ if($checkbox[$i]){ $sql = mysql_query("DELETE FROM $tbl_name WHERE cid='$i'")or die(mysql_error()); } } echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete.php\">"; } mysql_close(); ?> </table> </form> </td> </tr> </table> Firstly, i expect you needed to get the variables from the post superglobal array. Second, you need to check if each of the checkboxes have been ticked: if($checkbox[$i]){ $sql = mysql_query("DELETE FROM $tbl_name WHERE cid='$i'")or die(mysql_error()); } and third, you needed cid to equal $i, as that is the id which you are checking within the loop.
  3. Try: <?php function worddisplay($wordcount,$find,$result) { if ($wordcount == 2) { $find1 = $find[1]; $data = mysql_query("SELECT * FROM registrations WHERE register_companyName = '$find1' or register_contactPerson = '$find1' or register_telephoneNumber = '$find1' or register_telephoneNumber2 = '$find1' or register_faxNumber = '$find1' or register_cellphoneNumber = '$find1' or register_emailAddress = '$find1' or register_website = '$find1' or register_address1 = '$find1' or register_address2 = '$find1' or register_area = '$find1' or register_suburb = '$find1' or register_province = '$find1' or register_country = '$find1' or register_postalCode = '$find1' or register_business = '$find1' or register_description = '$find1' or register_trading = '$find1' or register_Mcat = '$find1' or register_keyword1 = '$find1' or register_keyword2 = '$find1' or register_keyword3 = '$find1' or register_keyword4 = '$find1' or register_keyword5 = '$find1' or register_keyword6 = '$find1' or register_keyword7 = '$find1' or register_keyword8 = '$find1' or register_keyword9 = '$find1' or register_keyword10 = '$find1' or register_keyword11 = '$find1' or register_keyword12 = '$find1' or register_keyword13 = '$find1' or register_keyword14 = '$find1' or register_keyword15 = '$find1' or register_keyword16 = '$find1' or register_keyword17 = '$find1' or register_keyword18 = '$find1' or register_keyword19 = '$find1' or register_keyword20 = '$find1' or register_latitude = '$find1' or register_longitude = '$find1'"); //$result = mysql_fetch_array( $data); while ($result = mysql_fetch_array( $data)) { if ($result == "") { $find1 = $find[0]." ".$find[1]; $data = mysql_query("SELECT * FROM registrations WHERE register_companyName = '$find1' or register_contactPerson = '$find1' or register_telephoneNumber = '$find1' or register_telephoneNumber2 = '$find1' or register_faxNumber = '$find1' or register_cellphoneNumber = '$find1' or register_emailAddress = '$find1' or register_website = '$find1' or register_address1 = '$find1' or register_address2 = '$find1' or register_area = '$find1' or register_suburb = '$find1' or register_province = '$find1' or register_country = '$find1' or register_postalCode = '$find1' or register_business = '$find1' or register_description = '$find1' or register_trading = '$find1' or register_Mcat = '$find1' or register_keyword1 = '$find1' or register_keyword2 = '$find1' or register_keyword3 = '$find1' or register_keyword4 = '$find1' or register_keyword5 = '$find1' or register_keyword6 = '$find1' or register_keyword7 = '$find1' or register_keyword8 = '$find1' or register_keyword9 = '$find1' or register_keyword10 = '$find1' or register_keyword11 = '$find1' or register_keyword12 = '$find1' or register_keyword13 = '$find1' or register_keyword14 = '$find1' or register_keyword15 = '$find1' or register_keyword16 = '$find1' or register_keyword17 = '$find1' or register_keyword18 = '$find1' or register_keyword19 = '$find1' or register_keyword20 = '$find1' or register_latitude = '$find1' or register_longitude = '$find1'"); //$result = mysql_fetch_array( $data); while ($result = mysql_fetch_array( $data)) { return ($result); } } else { return (mysql_fetch_array($data)); } } } } $result = worddisplay($wordcount,$find,$result); { echo($result['register_companyName']; } ?>
  4. I suggest you echo the contents of the query string after you attempt to do the query: $result = mysql_query($query) or die("SQL Error: Function search_fields - unable to select<br /><br />SQL = {$sql}<br /><br />".mysql_error()); echo 'SQL: '.$sql'<br />'; That way you can see exactly what is being passed into the query. I susepect there is a problem with a variable, and while it may not cause a syntax error and thus a mysql error, it will cause your query to function incorrectly.
  5. when you declare your function: function myfunction($var1,$var2,$var3='foobar'){ //function } And when you use you function myfunction($somevar,$someothervar); As you will notice, the third variable in the function definition was given a value. This makes the parameter optional. You can still pass a value for that function, or you can leave it as the default.
  6. Do you think you could explain in a bit more detail what you're trying to achieve? I personally am a bit confused. Also, you'd be far better off naming your topic with a relevant subject.
  7. If you want a time delayed redirect, you'll need to echo out some javascript. PHP cant modify the headers(such as redirecting the page) once you've output something to the screen.
  8. Maybe there is a problem with your sessions. Try echoing $_SESSION['username'] and $_SESSION['password']. Perhaps they are not being set properly when someone logs in?
  9. Well this: <?php session_start(); $username = $_SESSION['username']; $password = $_SESSION['password']; if(isset($_SESSION['username']) && isset($_SESSION['password'])) { echo "Welcome ".$username." (<a href=logout.php>Logout</a>)"; } else { echo "Welcome Guest! <br> <a href=login.php>Login</a> | <a href=register.php>Register</a>"; } ?> Works fine for me. I wonder if you accidently changed the wrong thing?
  10. Yeah, it is just a way to show that the file gets included. Although you could just name it file.inc, unless your server is set up so that php will parse files with extensions of .inc(and even then you get portability issues), then it tends to be a security issue. Often includes may contain sensitive data (database connection info etc) and just giving the file the extension .inc could allow someone to view the file in plain text. So, people name it file.inc.php, so it is still always parsed by php, but also shows that its an included file.
  11. You're missing the semi colon at the end of the line before: <?php $A = 'Hello'; $B = 'World'; $C = 'Beautiful'; $D = 'Day!'; $composite = $A .'|' . $B . '|' . $C . '|' . $D;// echo $composite; ?>
  12. By the way, there's a whole thread here about good php books: http://www.phpfreaks.com/forums/index.php/topic,58799.0.html
  13. Well, unless you can put those variables into an array, or unless the variable names follow a pattern, then your only choice is going to be: $composite = $var1.'|'.$var2.'|'.$var3.'|'.$var4;//etc
  14. You say you're not outputting anything to the screen, but two things: firstly, did you check through your included files to make sure they dont ouput anything. Second, dont forget about whitespace. The blank line at the top of the code you posted looks to me like it could be some whitespace - perhaps a newline character. You'll need to remove that too.
  15. Looks to me like the reason is just the order that the script runs. You fill in the info, hit submit: 1.) pulls the OLD data from the database. 2.) Display this in the form 3.) Update the data If you change it around a bit, you should get it working.
  16. Ok, so you'll need to make your headings into links, and pass a couple of variables through. The way ive set it up is that one click on the link would order ASC, a second would order DESC. <?php $db = mysql_connect("localhost","root","pass") or die("Problem connecting"); mysql_select_db("testing") or die("Problem selecting database"); //set a direction for the search. If none is set, we'll choose ASC if(!isset($_GET['direction'])){ $direction = 'ASC'; }else{ $direction = $_GET['direction']; } //set the newdirection as the opposite to the old if($direction=="ASC"){ $newdirection= "DESC"; }else{ $newdirection = "ASC"; } //change the query if we are ordering by something if(isset($_GET['orderby'])){ $query = "SELECT * FROM teaching ORDER BY '$_GET[orderby]' $direction"; }else{ $query = "SELECT * FROM teaching"; } $result = mysql_query($query) or die ("Query failed"); //let's get the number of rows in our result so we can use it in a for loop $numofrows = mysql_num_rows($result); echo "<TABLE class=\"maintable\" BORDER=1 frame=box width=100% CELLPADDING=0 CELLSPACING=1 >\n"; echo "<TR bgcolor=\"lightblue\"> <TD><a href='".$_SERVER["PHP_SELF"]."?orderby=startdate&direction=".$newdirection."'>Start Date</a></TD> <TD>Title</TD> <TD>Education</TD> <TD>Institution</TD> </TR>\n"; for($i = 0; $i < $numofrows; $i++) { $row = mysql_fetch_array($result); //get a row from our result set if($i % 2) { //this means if there is a remainder echo "<TR bgcolor=\"#CCFFCC\">\n"; } else { //if there isn't a remainder we will do the else echo "<TR bgcolor=\"#BFD8BC\">\n"; } echo" <TD>".$row['start_date']."</TD> <TD><a href='/showall.php?primary_index={$row[primary_index]}'>".stripslashes($row[title])."[/url]</TD> <TD>".$row['education']."</TD> <TD>".$row['institution']."</TD> \n"; echo "</TR>\n"; } //now let's close the table and be done with it echo "</TABLE>\n"; mysql_free_result($result); ?> Ive only done the first one, and this assumes your field name is startdate, if its not, you'll need to modify the link. Edit: i see i was beaten to it, but ill still post this as it might give you some more ideas.
  17. Ah i see, try something like: <table border="1"> <?php $query = mysql_query('SELECT `id`, `name` FROM `categories` ORDER BY `name` ASC'); $number_in_row = 2;//edit to however many you want $cellwidth = 100/$number_in_row; $x = 0; while ($category = mysql_fetch_assoc($query)) { if($x % $number_in_row == 0) echo '<tr>'; echo '<td width="'.$cellwidth.'"><a href="browse_files.php?catid='.$category['name'].'">Category 1</a></td>'; if(($x+1) % $number_in_row == 0) echo '</tr>'; $x++; } //fill in with empty cells while(($x % $number_in_row != 0)){ echo '<td width="'.$cellwidth.'"> </td>'; $x++; } ?> </tr></table> I even made it easy for you to change the number in each row
  18. I would suggest the best way is to try and think of some things to learn how to do. Try and find out how to do something with the contents of an html form, for example. There are some beginner tutorials on phpfreaks: http://www.phpfreaks.com/tutorials.php Try and figure out what some of the bits of code might do. If all else fails, buy a book
  19. Hmm, to debug that, try echoing the query after you try it: $query="UPDATE traits SET title='$title', genre='$genre', character_name='$character_name', role='$role', height='$height', hair='$hair', eyes='$eyes', weight='$weight', age='$age', clothing='$clothing', dwelling='$dwelling', growingup='$growingup', family='$family', relationships='$relationships', goals='$goals', motivations='$motivations', fears='$fears', loves='$loves', weaknesses='$weaknesses', positives='$positives', negatives='$negatives' WHERE username = '$_SESSION[$username]'"); $update=mysql_query($query) or die("<br>Error: ". mysql_error(). " with query : ". $query); echo '<br />Query: '.$query.'<br />'; This will check the correct values of the variables are being put into the query - for example, i would be suspicious of a problem with the session.
  20. Do you mean you want a list of 10, with links underneath such as Previous and Next, or maybe page numbers? (rather like the likes to the various pages on this forum) In which case, look into using pagination. Take a look at these tutorials to help you out: http://www.phpfreaks.com/tutorials/43/0.php http://www.phpfreaks.com/tutorials/73/0.php
  21. Unless im being blind, you've not yet done anything to only allow these options to certain people. I would suggest the best method is to query the database for the user who is currently logged in(e.g. get their username/id from the session), and then only display these options if they are an admin etc. For example, lets suppose you have a field called user_level in your users table: <?php $sql = mysql_query("SELECT `user_level` FROM `users` WHERE `username`='$_SESSION[username]'") or die(mysql_error()); $status_level=mysql_result($sql,0,"user_level"); if($status_level >= 3){//im guessing you might have more that one level of staff //show various options } ?> Dont forget, if these options are links to php files, you'll want to check that the user accessing those pages has the right user level. Also, you might want to consider putting this into a file that you'll include where necessary, or maybe a function to check for the right level.
  22. Ok, i suggest you email goddady back and ask them if you HAVE to use their mailer. Ask them if you can use your own. It sounds to me like they've set up something to help people send emails, but it may be that the script you've bought is more suited to your needs. If it is the case that godaddy only permit the use of their emailer, then that is why the script you bought does not work.
  23. I suspect the problem is that you're trying to query the query, if you see what i mean(take note of the comments): <?php if (isset($_POST['submit'])) { $title=$_POST['title']; $genre=$_POST['genre']; $character_name=$_POST['character_name']; $role=$_POST['role']; $height=$_POST['height']; $hair=$_POST['hair']; $eyes=$_POST['eyes']; $weight=$_POST['weight']; $age=$_POST['age']; $clothing=$_POST['clothing']; $dwelling=$_POST['dwelling']; $growingup=$_POST['growingup']; $family=$_POST['family']; $relationships=$_POST['relationships']; $goals=$_POST['goals']; $motivations=$_POST['motivations']; $fears=$_POST['fears']; $loves=$_POST['loves']; $weaknesses=$_POST['weaknesses']; $positives=$_POST['positives']; $negatives=$_POST['negatives']; $update="UPDATE traits SET title='$title', genre='$genre', character_name='$character_name', role='$role', height='$height', hair='$hair', eyes='$eyes', weight='$weight', age='$age', clothing='$clothing', dwelling='$dwelling', growingup='$growingup', family='$family', relationships='$relationships', goals='$goals', motivations='$motivations', fears='$fears', loves='$loves', weaknesses='$weaknesses', positives='$positives', negatives='$negatives' WHERE username = '$_SESSION[$username]'";//this should just be the contents of the query, not performing the query itself if (mysql_query($update)) {//because you do the query here echo "<center>Data saved succesfully! </center>";} else { echo "<br>Query failed: " . mysql_error(). $update;} } ?>
  24. From thorpe's signiture: http://hudzilla.org/phpwiki/index.php?title=Main_Page Looks pretty good to me as well.
  25. Ok, yes the problem is here. On your call to your function, you simply have: addNewPic(); The function, however, requires parameters to be put into it. It requires all of the following: $dbase,$filein,$fileout,$imagethumbsize_w,$imagethumbsize_h,$green,$blue,$red If you dont fully understand functions, try googling them. First thing i found for an introduction to functions: http://www.onlamp.com/pub/a/php/2001/07/12/php_foundations.html
×
×
  • 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.