Jump to content

Lokolo

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Posts 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. 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?

  3. 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

     

     

  4. 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! :P)

  5. 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

  6. 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

  7. 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!

  8. 	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?

  9. 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!

  10. 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";

    } ;

  11. ok using the above code (fixed - i missed mysql_query - i don't know what i was thinking, as i said, very tired :P )

     

    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

  12. 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,

  13. 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

  14. $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.