Jump to content

Lokolo

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by Lokolo

  1. Ok I have been told this before, but in such a way that it just goes right over my head. (I have always learn that " " for strings, ' ' for ints, but I can't use " " so I went for ' ' but this also doesn't work in this case). So for things like SESSION and POST, inside the square brackets, should I always try and use quotes of some sort, but why? Thanks if you can explain in simple Lokolo terms p.s. omg why did i not see it, the lines below have the quotes taken out of them ARGH
  2. http://pastebin.com/m66e4c3a0 I pasted it on there. Now I have counted the {'s brackets and its not that, but I cannot see anything else. I just thought 2+ heads is better than 1. Its line 14 btw. (although my actual page is a lot larger but I thought I only needed that part). Thanks for any help
  3. I am on Vista by the way, just before I explain the problem. ok so I have installed Apache 2.2.4 and this all works (I can get onto http://localhost and it says "It works"). Now I am trying to install PHP 5.2.4 and I put everything correctly to my knowledge, however, at the end of the installation it did say there was a script missing, which is what I was thinking is the problem, so I cannot load PHP files. From a few installation tutorials it seems the PHP should add something to the httpd.conf but I am not sure what, the "Load" thing but I am not sure what the actual command is. Also I have 2x httpd.exe processes running, is this right? (ones 1,856k, the other 4,388k) So anyone could help?
  4. i had tried to return thing but that didn't work either. it was the == thing. thanks everyone
  5. hm i keep doing this. its not even funny anymore. im use to other programming. i'll try that but not sure if it'll work. (as you can see in the other if statement below i did use == rather than = so i do know some things hehe ) i'll try that out
  6. This is my function: function filenamecreator(&$newfilename) { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $newfilename = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $newfilename = $newfilename . $tmp; $i++; } I can use it in the main program it works however i use it in another function, the code used below $flag = 0; while ($flag = 0) { $flag = 1; filenamecreator($newfilename); $get_otherfilenames = mysql_query("SELECT * FROM logfileinfo"); $num=mysql_numrows($get_otherfilenames); $count = 0; while ( $count < $num ) { $otherfilename = mysql_result($get_otherfilenames, $count, "filename"); if ( $newfilename == $otherfilename ) { $flag = 0; } $count++; } } $add_logfile = mysql_query("INSERT INTO logfileinfo (hotelID, filename) VALUES ('$hotelID','$newfilename')"); However, its not adding $newfilename as anything (i.e. its "") Hope someone can help! Thanks
  7. ah. they user doesn't upload it. I create it! i create and update the log. the only things they can do are download and upload. the only thing I can now think of is create a MySQL table with the hotelID and Encryption i create the encryption completely randomly, check if one already exists (just incase), and then store it. hotelID Encryption 1 ab5nsj478sn 2 384jfn39jd0 3 83ncnc93j9 so files would be ab5nsj478sn.txt , 384jfn39jd0.txt, 83ncnc93j9.txt then when updating/downloading etc. I can just get the encyrption from the table. Thoughts? (I would use your code but I am not exactly experienced! )
  8. Ok so I have some code case "Download Log": echo "Downloading... <br><br>"; rename("$_SESSION[hotelID].txt", "log.txt"); //download file break; but I am not sure how to get it to download the file. (on the //download file bit). _____________________ the next thing. as you can see from the above the files are based around the hotelID. how can I stop people typing www.url.com/1.txt and then gaining access to the files? (if this is possible) - I was thinking of having the hotelID go through some sort of algorithm like (*56 + 50)*4 to make the file name (so ID 1 would be file 424.txt - am I thinking correctly? If so how could I encrypt it better, such as adding letters to the name. _____________________ Wow long, should be simple enough for the uber programmers, thanks, Lokolo
  9. Passing by refence is done by putting an & sign in the fucntion define i.e. function(&$variable) { } will pass it back. for anyone that wants to know.
  10. I can't figure out how to do it. so if i have this code $count = 5; somefunction($count); echo "$count <br>"; -------------------- somefunction($count) { $count = 1000; } but obviously the echo will print off 5, not 1000, which is what I want. w3schools goes on about the return syntax but that only works when the function is returning 1 value! hope you can help (and understand what I am on about), Lokolo
  11. ok will try that. however, i got it to work by removing the echo "$_SESSION[totalcost] <br>"; echo "$_SESSION[funds] <br>"; statements, as a PHP Expert (you seem to be answering everyones questions with ease) why could this be?! [edit] your way worked. hm i deleted a few statements and it didnt work again, so used yours, and harruh!
  12. echo "$_SESSION[totalcost] <br>"; echo "$_SESSION[funds] <br>"; IF ( $_SESSION[funds] < $_SESSION[totalcost] ) { echo "You do not have enough cash to upgrade <br>"; } ELSE { echo "Upgrading... <br>"; } Output: 75,000 622,500 You do not have enough cash to upgrade I have no idea why. What reasons could it be?
  13. indeed - i tried that but it then just goes back to the first form. obviously that value of submit is wiped as soon as i touch the 2nd form. (if you understand me) not sure how i can get around this though
  14. ok basically i have 2 forms, one shows up at the start, that gets submitted and the page refreshes wth the 2nd one. however, i cannot figure how to submit the 2nd one as the forms are both submit forms. (basically once i submit the first one, it then goes to the elses of both. i can get the 2nd form to display if i change the 2nd !isset($_POST['submit']) to something else but then i can't submit that one) <? if (!isset($_POST['submit'])) { ?> <h2> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return checkSubmit(this);"> Number of Rooms: <input type="text" size="3" multiple style="height: 20px" maxlength="2" name="numrooms"> <input type="submit" name="submit" value="Upgrade"> </form> </h2> <? } else { upgradehotel($_POST['numrooms']); if (!isset($_POST['submit'])) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return checkSubmit(this);"> <input type="submit" name="confirm" value="Yes"> <input type="submit" name="confirm" value="No"> </form></h2> <? } ELSE { echo "work damnit work"; } ?> heh thanks!
  15. oh nice one, guess i gotta learn those good old string functions...
  16. Currently in my DB table i store the funds as a numeric so 1000, or 101000 - but how do I put a comma in? Simple as really but no idea how to do it heh. thanks,
  17. ok if you have the url in a field then thats all good set the url to a variable so like $url then do the regular image thing with HTML so like <img src="$url"> (I think) so if ( field = 1 ) { <img src="$url"> } else { echo "you do not have priviledges to have a picture"; } ;
  18. it doesn't matter now - i figured it out - it wasn't keepin it as a numeric, sorted it now though
  19. ok using the above code (fixed - i missed mysql_query - i don't know what i was thinking, as i said, very tired ) however the echos gave: Array 0 hm ignore the Array thing - i have typed in the wrong variable name LOL. the 0 however, is the stored value for the new stayinglegnth - which shouldn't be 0!!!!! RAR
  20. if ( field = 1 ) { display image } else { don't display image }
  21. ok from what I know (not a lot but still) you use ' around variables you use ` around table names and you use " around commands (such as echo "hello" or "SELECT...." )
  22. i am getting mysql fetch array error now hm $get_newvalues = ("SELECT * FROM `rooms` WHERE roomID = '1'"); $funnyrow = mysql_fetch_array($get_newvalues); $thevariable = $funnyrow['stayinglength']; $secondvar = $funnyrow['guest']; echo $funnyrow; echo $thevariable; on '$funnyrow = mysql_fetch_array($get_newvalues);' <-- that line i know im being a n00b but my brain hurts thanks,
  23. nope 4. using phpdev and that came with mysql4 and phpmyadmin 2.3.2 um, well what i did before was $updatedstayinglength = $stayinglength - 1 i thought that would keep it as a numeric - obviously not. anyway or sorting this out? (i have no idea - a link will do if you don't want to explain) thanks, Lokolo
  24. $update_guestsstaying = "UPDATE `rooms` SET stayinglength='$updatedstayinglength' WHERE roomID='$roomID'"; ok its setting the stayinglength to 0 when roomID = '$roomID' instead of setting it to the $updatedstayinglength i can echo $updatedstayinglength and it will give the number 4 for example, yet when i run that it updates it to 0. I know its most probably the most obvious thing but I have been snipping/changing etc. for an hour now and cannot see why its not updating it to the variable. 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.