Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. I think that sounds likely, i had a very similar problem. I believe it happens only if register_globals is on.
  2. indeed, to declare a session simply do: $_SESSION['sessioname'] = "Session value";
  3. Welll yes, although the image itself isn't in the database, you can contain all the information about it and its url.
  4. Yes, you include a php file.
  5. So you want all the data from one field in one array, all the data from another in another array? [code] <?php $sql = mysql_query("SELECT * FROM `yourtable`"); while($row = mysql_fetch_assoc($sql)) { $field1= $row[field1]; $field2= $row[field2]; $field3= $row[field3]; $array1[] = $field1; $array2[] = $field2; $array3[] = $field3; } $array1 = array_unique($array1); $array2 = array_unique($array2); $array3 = array_unique($array3); ?> [/code] That should do it.
  6. Ah yes, a switch statement is probably better here...i always seem to forget about those.
  7. A better way to do it might be use includes: [code] <?php include ("http://www.evermoreforums.com/wes/header.php"); $page = $_REQUEST['page']; if($page == "basics") { include("basics.php"); } elseif($page == "likes") { include("likes.php"); }else{ include("defaultpage.php"); [/code] If you do it like this, you can avoid having a massive file.
  8. Do you already have a database with the content for each treatment each with a corresponding id?
  9. $content = $_GET[content]; $id = $_GET[id]; $sql = mysql_query("SELECT * FROM `table` WHERE `content`='$content' and `id`='$id'"); then grab the information you need and display it.
  10. Umm, i was only trying to make the script work!
  11. What sort of time are you trying to validate? The function would depend on what the input is acually supposed to be.
  12. No problem, it was a nice thing to solve :)
  13. Toonmariner, shouldn't this: $qry = mysql_query($qry); $row = mysql_fetch_row($nf); $nf = $row[0]; $nh = $row[1]; $nm = $[2]; be this: $qry = mysql_query($qry); $row = mysql_fetch_assoc($qry); //you need to use the variable that did the query $nf = $row[nfarms]; $nh = $row[nhomes]; $nm = $row[nmines]; Because we dont know if the fields are in that order, it would be better to use an associative array.
  14. might be an easier way, but i created a second array with keys and used array_combine: [code] <?php $arr1 = array('5','7','1','4','6','3','2'); $arr2 = array('3','5','4','7'); foreach($arr2 as $check) {   $i = 0;   while($i < count($arr1))   {       if($check == $arr1[$i]){   $newarray[$i] = $check; } $i++; } } ksort($newarray); $i=0; while($i< count($newarray)){   $keys[$i]= $i;   $i++; } $newarray = array_combine ($keys, $newarray); print_r($newarray); ?> [/code]
  15. I think you would want to use UPDATE here... $query = "UPDATE photos SET comments='$comment_tmp' WHERE id='91';
  16. this is what ive got so far: [code] <?php $arr1 = array('5','7','1','4','6','3','2'); $arr2 = array('3','5','4','7'); foreach($arr2 as $check) {   $i = 0;   while($i < count($arr1))   {       if($check == $arr1[$i]){   $newarray[$i] = $check; } $i++; } } ksort($newarray); print_r($newarray); ?> [/code] The output from that is: Array ( [0] => 5 [1] => 7 [3] => 4 [5] => 3 ) Im just trying to figure out how to re-do the keys so you have 0,1,2,3 as keys instead. Im sure theres a function somewhere...
  17. Its up to you, you could try looking around for a pre-built CMS (Content management system) or try to make your own smaller version, either way your going to need a database. you are basically going to have a database table containing a treatment title, the contents of the page about the treatment and any other info. You would then have a page that would pull all the titles from a database and show a link to them. Alternatively, you could investigate using file uploading if you are wanting people to upload their own html files, and then you would probably only need to store the url of the file and the title in a database. However you do it, its not going to be all that simple, perhaps it might be better trying out some other php tutorials to get a better understanding of it first.
  18. I think you are going to need to check each date to make sure that the room is free...I would have thought you could modify Barand's code above to do this.. [code] <?php $room = 1; $arrival = '2006-07-02'; $nights=5; $arr_time = strtotime($arrival); for ($i=0; $i<$nights; $i++) { $booked_date = date('Y-m-d', strtotime("+$i days", $arr_time)); $sql = mysql_query("SELECT * FROM bookings WHERE room='$room' and booking_date='$bookingdate'"); $num = mysql_num_rows($sql); if($num != "0"){ echo "The room is not available on those dates"; exit; } ?> [/code] I would think that should work, but its untested.
  19. If you go straight to the header.php file, does that output something?
  20. Personally, i find phpdesigner 2006 a really great editor. If you download the php file then it passes your code and checks for syntax errors; because thing like ' " ( and { must also have a closing ' " ) }, it puts two of them in if you type one and positions the cursor in the midde(this can be turned off); if you highlight an opening or closing bracket (/) it highlights the other to help with checking logic. And of course it does things like syntax highlighting and giving function prototypes.
  21. Can you echo the $query variable, to double check what is being passed to it?
  22. Umm, try echoing the query and adding an or die statement? $query="SELECT * FROM nuke_seccont WHERE secid like '$platform' AND developer like '$developer' AND publisher like '$publisher' AND fletter like '$fletter' ORDER BY $sortby DESC"; echo $query; $result = mysql_query($query) or die(mysql_error());
  23. You might also find it easier to do it like: while ($row = mysql_fetch_assoc() { $artid = $row[artid]; etc }
  24. Im not sure if this is the only problem, but the form action is POST, and you are trying to retrieve the variables using GET. Also, if you are intending on using wildcard searches with %, you will need to use LIKE instead of = in your query e.g.: developer like '$developer'
  25. I dont understand what the problem is relating to your tables and the field, suppliers, could you explain that some more? As for the other problem, just change the value to the county name: <option value="Aberdeenshire">Aberdeenshire</option>
×
×
  • 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.