Jump to content

le007

Members
  • Posts

    122
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

le007's Achievements

Member

Member (2/5)

0

Reputation

  1. Found the issue - the save page was saved in unicode. I changed it back to ansi. Maybe this will help someone else out in the future.
  2. Hi all, I don't know why the data isn't getting written to my flatfile database but its not! Any help would be superb. Thank you The edit page looks like this: <?php $listings=file("bookings.txt"); $no_of_bookings=sizeof($listings); for($i=0; $i<$no_of_bookings; $i++) { $details=explode("\t",$listings[$i]); echo "<input type=\"text\" name=\"booking[$i][]\" value=\"$details[0]\">"; echo "<input type=\"text\" name=\"booking[$i][]\" value=\"$details[1]\">"; echo "<input type=\"text\" name=\"booking[$i][]\" value=\"$details[2]\">"; echo "<input type=\"text\" name=\"booking[$i][]\" value=\"$details[3]\">"; echo "<br>"; } ?> The save page looks like this: <?php $bookings=""; foreach($_POST["booking"] as $booking) { $bookingLine=implode("\t",$booking); $bookings.=$bookingLine."\n"; } $fh=fopen("bookings.txt","w+"); if(fwrite($fh,$bookings)) { echo "Changes Saved successfully..."; } else { echo "Failed to save changes..."; } fclose($fh); ?> </b> <br> <br> <br> <a href="switch.php">Click here for Admin Area</a> All that is appearing is Click here for Admin Area - nothing else....... please fix this as its something small???? Thank you all, Le007
  3. Right ok I gotta get outta here for a few minutes - ok I'll go with your advice and try the second table. You've helped out a lot, thanks a heap. I've just literally tried any letter and indeed it works. It produces both results - I'm quite happy with the progress done already, its a decent enough start considering I didnt even know how to connect to the db initially. I'm learning though..... Cheers Darkwater, back soon.
  4. Amazingly, it works? Someone it recogonises any word in the keyword field and produces the correct corresponding data......
  5. Well I had $row in already to select everything so I didn't wanna duplicate the variable name - I now have form sending A singular keyword to the this page and it is recogonising it fine - its printing the correct corresponding data. I need to do a lot of work to it now though. I need to see if it'll work if one word is entered even if two words are in the keyword field and obviously enough delve into the whole 'common words' issue. Thanks though buddy, I'm getting there. <?php $conn = mysql_connect("localhost", "root", "") OR die ('Could not connect to mySQL: ' . mysql_error());; mysql_select_db("wow") OR die ('Could not select a Database: ' . mysql_error()); $sql = mysql_query("SELECT * FROM one") OR die(mysql_error()); while ($row = mysql_fetch_assoc($sql)) { echo $row['keyword'] . "<br />"; echo $row['link'] . "<br />"; echo $row['description'] . "<br />"; } $searchy=$_REQUEST['search']; $result = mysql_query("SELECT * FROM one WHERE keyword like '%$searchy%' ") or die(mysql_error()); while($row1 = mysql_fetch_array($result)){ echo $row1['keyword'] . " " . $row1['link']. " " . $row1['description']; echo "<br />"; } ?>
  6. *Snap* I was working on it and got it this way, not sure if its as efficient: while($row1 = mysql_fetch_array($result)){ echo $row1['keyword'] . " " . $row1['link']. " " . $row1['description']; echo "<br />"; }
  7. Just for testing I tried this: $result = mysql_query("SELECT * FROM one WHERE 'keyword' LIKE 'Peter' ") or die(mysql_error()); echo $result; Got that whole resource '4 thing again and I really did read all your comments - I understand that its just telling me what php is doing.
  8. Yep I did read your post and got it all done. Excellent - at least thats working and inserting properly which is always nice On paper it doesnt look like an overtly huge project: DB connect form -> post data grab data match data from the form to a link and description I guess it relays all back to the whole standard word phrase, 'and', 'or', 'the' etc.
  9. Ok yep - that worked a charm. Now on to challenge two - getting keywords from a posted form and matching them to link and desc Fun and games ahead :L
  10. Not a problem Darkwater - thanks. So far I'm about here: <?php $conn = mysql_connect("localhost", "root", "") OR die ('Could not connect to mySQL: ' . mysql_error());; mysql_select_db("db1") OR die ('Could not select a Database: ' . mysql_error()); $sql = "SELECT * FROM one"; $data = mysql_query( $sql ) or die( "Could not get threads" ); while ( $data2 = mysql_fetch_array( $data ) ) { $keyword = $data2[keyword]; // fill in other 2 $link = $data2[link]; $description = $data2[description]; echo $keyword; echo $link; echo $description; } But I'm fighting on - gunna get this one way or the other, some good guys like yourself have helped me out and I do know the fundamentals involved - I'm expert on css and obviously enough html but php has eluded me somewhat - I just haven't needed it too much up until this point. I do now though. I'm just toying with the db to try and figure it out first. I really then need to make a form - post the data to the about code and use the like expression. I know earlier akitchen gave me all the code I just need to piece it together - do you think your way is easier? Regards, Le007
  11. thanks for the help fellas, i just inserted data no problem and then I did the $sql = "SELECT * FROM one"; $data = mysql_query( $sql ) or die( "Could not get threads" ); while ( $data2 = mysql_fetch_array( $data ) ) { $link = $data2[link]; // fill in other 2 } it worked, I got one piece of data back, where do I put the others to get the rest of it? I just thought if I put select * it would show everthing in the table, I guess not......
  12. I just tried mysql_query("INSERT INTO one (keyword, link, description) VALUES ('Peter', 'Griffin', '35')"); and it did insert the data.....
  13. No, it seems to be connecting alright, no error message - I'll try and insert something to the field and see if that works.
  14. thanks for the help, my fields are actually keyword, link and description - i tried the following and didnt get any data back at all, just the keyword is link is description is? <?php $conn = mysql_connect("localhost", "root", "") or die; mysql_select_db("table1", $conn); $date = $_POST['keyword']; $time = $_POST['link']; $day = $_POST['description']; $query = "SELECT * FROM one"; $result = mysql_query($query) or trigger_error("Query: $query <br/>mysql Error: " . mysql_error()); echo "keyword is $date"; echo "link is $time"; echo "description is $day"; ?>
  15. <?php $conn = mysql_connect("localhost", "root", "") or die; mysql_select_db("datab", $conn); $result = mysql_query("SELECT * FROM one"); echo $result; ?> I have data in three fields as follows: date time day All is written is this "Resource id #3" ?????? Any ideas? Thanks
×
×
  • 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.