Jump to content

mike12255

Members
  • Posts

    439
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by mike12255

  1. Im trying to use move_uploaded_file() to move an uploaded file from the temp directory to a different directory and when I run this function I get this error:

     

    Warning: move_uploaded_file(/home/mikeh/public_html/uzErUpl0ds/jx8zmPQW.rtf) [function.move-uploaded-file]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/fileupload.php on line 238

     

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/Applications/XAMPP/xamppfiles/temp/phprQRBDe' to '/home/mikeh/public_html/uzErUpl0ds/jx8zmPQW.rtf' in /Applications/XAMPP/xamppfiles/htdocs/fileupload.php on line 238

    There was an error uploading the file, please try again!

     

    I have no idea why, below is my code:

     

    <?php
    
    $target_path = $uploadLocation . basename( $_FILES['upfile']['name']);
    $ext = end(explode('.', $_FILES['upfile']['name']));
    
    
      function generatePassword ($length = 
      {
    
        // start with a blank password
        $password = "";
    
        // define possible characters - any character in this string can be
        // picked for use in the password, so if you want to put vowels back in
        // or add special characters such as exclamation marks, this is where
        // you should do it
        $possible = "_12346789abcdfghjkmnpqrtvwxyzABCDFGHJKLMNPQRTVWXYZ";
    
        // we refer to the length of $possible a few times, so let's grab it now
        $maxlength = strlen($possible);
      
        // check for length overflow and truncate if necessary
        if ($length > $maxlength) {
          $length = $maxlength;
        }
    
        // set up a counter for how many characters are in the password so far
        $i = 0; 
        
        // add random characters to $password until $length is reached
        while ($i < $length) { 
    
          // pick a random character from the possible ones
          $char = substr($possible, mt_rand(0, $maxlength-1), 1);
            
          // have we already used this character in $password?
          if (!strstr($password, $char)) { 
            // no, so it's OK to add it onto the end of whatever we've already got...
            $password .= $char;
            // ... and increase the counter by one
            $i++;
          }
    
        }
    
        // done!
        return $password;
    
      }
      
      
    $filename = generatePassword();
    $filename = $filename.".".$ext;
    
    $filelocation = "/home/mikeh/public_html/uzErUpl0ds/".$filename;
    
    $allowed = "doc docx rtf txt pdf xls";
    $allow = explode (" ",$allowed);
    
    
    if (in_array($ext,$allow)){
    
    if(move_uploaded_file($_FILES['upfile']['tmp_name'], $filelocation)) {
    //TODO: Insert date regex format and make the catagory selection auto//
    $uid = $_POST['catagory'];
    $name =$_POST['title'];
    $author = $_POST['author'];
    $cat = $_POST['code'];
    $dt1=date("Y-m-d");
    $size = filesize($filelocation); 
    die($filelocation);
    
    $query = "INSERT INTO newnotes (uid, name, catagory, location, author, date, filesize) VALUES ('$uid', '$name', '$cat', '$filename', '$author', '$dt1','size')";
    //die ($query);
    $res = mysql_query($query) or die (mysql_error());
    
    
        echo "The file: ".  basename( $_FILES['upfile']['name']).
        " has been uploaded! It will be reviewed and if possible you will be granted credits within the next 24 hours.";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    
    }else{
    echo "You have tried to upload an file type that we do not allow. The current allowed types of files are, ".implode(',',$allow).". If you are trying to upload a note with a diffrent file extension please use <a href=\"contact.php\">this form</a> to let us know so we can fix our website to allow this type of file in the future.";	
    }
    
    ?>

  2. I got a table designed on photoshop (see below) and Im just curious how to do it. I assume That I would just make a div with the background image of the spiraley things that are inbetween the <Tr>'s and I can replace the background image of the Tr's with the gradiant image I have. My only issue is IF you can do both of those how do I space the Tr's out enough so that there is a little crack between them and you can see the div background image.

     

     

    scorew.gif

     

     

  3. Right now I got a menu bar sitting ontop of my header. In the menu bar on the far right (as in the FIRST picture below) i have a login form and a thing that displays the users. My issue is (as can be seen in the second picture) if I adjust the screen size it moves their position because I used absolute positioning to set them where I wanted. I am unaware of any other ways of how to do this so help is appriciated. Ill post my html and CSS below the pictures.

     

    What it should look like

     

    good.png

     

    What It looks like when I adjust browser size

     

    bad.png

     

    CSS Code:

     

    @CHARSET "UTF-8";
    
    * * {
    margin:0;
    padding:0;
    }
    
    body{
    background-color:black;
    }
    
    #box {
    margin-left:auto;
    margin-right:auto;
    width: 972px;
    background-color:white;
    margin-top:none;
    }
    
    #header {
    height: 222px;
    background-image:url('../images/header.jpg');
    z-index: 5;
    }
    
    #menu {
    background-image:url('../images/menu_bar.png');
    width: 972px;
    height: 72px;
    position: absolute;
    left: auto;
    top: 170px;
    z-index: 10;
    background-color: transparent;
    
    }
    
    
    #menu ul{
    list-style: none;
    padding: 0;
    margin: 0;
    }
    #menu li {
    z-index:20;
    width:57px;
    height:23px;
    text-align:center;
    float: left;
      	margin: 0 0.15em;
    background-image:url('../images/mb1.png');
    background-color: transparent;
    position:relative;
    left: 13px;
    top: 27px;
    
    }
    
    #menu li.sel {
    
    z-index:20;
    padding-top:1px;
    width:57px;
    height:23px;
    text-align:center;
    float: left;
      	margin: 0 0.15em;
    background-image:url('../images/mb2.png');
    background-color: transparent;
    position:relative;
    left: 13px;
    top: 27px;
    }
    
    #menu li a {
    
    background: none;
    color: black;
    font-size:14px;
    text-decoration: none;
    text-align: center;	
    }
    
    #menu li  a:hover {
    
    z-index:20;
    width:57px;
    height:23px;
    text-align:center;
    float: left;
      	margin: 0 0.15em;
    background-image:url('../images/mb2.png');
    background-color: transparent;
    position:relative;
    left: 13px;
    top: 27px;	
    }
    
    #shadow{
    background-image:url('../images/dropshadow.png');
    width:972px;
    background-repeat:repeat-x;
    position: absolute;
    left: auto;
    top: 229px;
    z-index: 15;
    background-color: transparent;	
    }
    
    #login{
    position: absolute;
    left: 600px;
    top: 199px;
    z-index: 20;
    color:black;
    background-color: transparent;
    border:none;
    }
    
    #login label{
    color: black;
    padding:0px;
    font-size: 13px;
    
    }
    /* Rounded Corner */
    #login input.tb5 {
    background: url('../images/rounded.png') no-repeat top left;
    height: 18px;
    padding:2px;
    border:none;	
    color:#8F0000;
    }
    #login inputround.tb5a {
    border: 0;
    width:220px;
    margin-top:3px;
    }
    
    
    #login input.btn {
    position: absolute;
    left: 170px;
    top: 3px;
    background: url('../images/btn.png') no-repeat top left;
    width:35px;
    padding:2px;
    color:white;
    border:none;
    }
    
    #login input.btn2 {
    position: absolute;
    left: 170px;
    top: 25px;
    background: url('../images/btn.png') no-repeat top left;
    width:35px;
    padding:2px;
    color:white;
    border:none;
    }
    
    #display_users{
    position: absolute;
    left: 810px;
    top: 222px;
    padding:2px;
    font-size:13px;
    color:black;
    z-index:40;	
    }
    
    #news_display table {
    Padding-top:8px;
    font-size:13px;
    background-color:black;
    color:white;
    z-index:5;
    }
    
    #news_display td.news {
    background: url('../images/table_top.gif');
    width:191px;
    padding:4px;
    padding-top:8px;
    margin-top:5px;
    color:white;
    z-index:4;
    }

     

    HTML Code:

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>CLan SGI</title>
    <LINK REL="SHORTCUT ICON" HREF="images/icon.ico" type="image/x-icon"> 
    <link rel = "stylesheet" type="text/css" href=" styles/main_style.css" >
    </head>
    <body>
    <div id = "box">
    
    <div id ="header"><img src="images/header.jpg"/></div>
    
    <div id="menu">
    <ul>
    <li class="sel"><a href ="index.html">Index</a></li>
    <li><a href ="Forums.html">Forums</a></li>
    <li><a href ="contact.html">Contact</a></li>
    </ul>
    
    
    
    </div>
    <!-- End of menu Div -->
    <div id="display_users">
    <img src="images/guy_icon.png" /> Users: 176 Members: 76
    </div>
    <!-- End of display_users div -->
    
    <div id="login">
    <form method="_POST" action="login.php">
    <label>Username</label> <input class="tb5" type="text" name="firstname" /><a href="reg.php"></a><input type="submit" name="reg" action="register.php" class ="btn" value="Reg." /></a><br />
    <label>Password</label> <input class ="tb5" type="password" name="lastname" /><input type="submit" action="login.php" name="login" class ="btn2" value="Login" />
    </form>
    </div>
    <!-- End of login div -->
    
    
    <div id= "shadow"> </div>
    
    
    <div id="news_display">
    <br/>
    <table>
    <tr><td class="news"> Latest Threads </td> </tr>
    <tr><td>ttest</td><td>test</td></tr>
    
    
    </table>
    </div>
    <!-- End Of News Display -->
    </div>
    <!-- End of box div -->
    </body>
    </html>

  4. Hello i made a class and im trying to assign an image I got to the first td however Its not working, below is my code I hope somone can spot my error.

     

    CSS:

    #news_display{
    Padding:2px;
    font-size:13px;
    color:white;
    }
    
    #news_display td.news {
    background: url('../images/table_top.gif');
    width:200px;
    padding:2px;
    color:white;
    }
    

     

    Html:

    <div id="news_display">
    <table>
    <tr><td class="news"> Latest Threads </td> </tr>
    <tr>
    <td>08/04</td><td>What happened to the last...</td><td>Jer0me</td></tr>
    <tr><td>08/04</td><td>What happened to the last...</td><td>Jer0me</td></tr>
    <tr><td>08/04</td><td>What happened to the last...</td><td>Jer0me</td></tr>
    <tr><td>08/04</td><td>What happened to the last...</td><td>Jer0me</td></tr>
    
    </table>
    </div>
    <!-- End Of News Display -->

     

  5. My menu bar is an image that is placed overtop the header. I am trying to add a login form to the right side of my menu bar (picture below) but for some reason my labels and textboxes have black backgrounds. I want their background to be see-through so that u see the menu bar behind them since its a gradient.

     

    issue.png

     

     

     

     

     

    Here is my CSS:

    @CHARSET "UTF-8";
    
    * * {
    margin:0;
    padding:0;
    background-color:black;
    
    }
    
    #box {
    margin-left:auto;
    margin-right:auto;
    width: 992px;
    margin-top:none;
    }
    
    #header {
    height: 222px;
    background-image:url('../images/header.jpg');
    z-index: 5;
    }
    
    #menu {
    background-image:url('../images/menu_bar.png');
    width: 972px;
    height: 72px;
    position: absolute;
    left: 13px;
    top: 170px;
    z-index: 10;
    background-color: transparent;
    
    }
    
    
    #menu ul{
    list-style: none;
    padding: 0;
    margin: 0;
    }
    #menu li {
    z-index:20;
    width:57px;
    height:23px;
    text-align:center;
    float: left;
      	margin: 0 0.15em;
    background-image:url('../images/mb1.png');
    background-color: transparent;
    position:relative;
    left: 13px;
    top: 27px;
    
    }
    
    #menu li.sel {
    
    z-index:20;
    padding-top:1px;
    width:57px;
    height:23px;
    text-align:center;
    float: left;
      	margin: 0 0.15em;
    background-image:url('../images/mb2.png');
    background-color: transparent;
    position:relative;
    left: 13px;
    top: 27px;
    }
    
    #menu li a {
    
    background: none;
    color: black;
    font-size:14px;
    text-decoration: none;
    text-align: center;	
    }
    
    #menu li  a:hover {
    
    z-index:20;
    width:57px;
    height:23px;
    text-align:center;
    float: left;
      	margin: 0 0.15em;
    background-image:url('../images/mb2.png');
    background-color: transparent;
    position:relative;
    left: 13px;
    top: 27px;	
    }
    
    #shadow{
    background-image:url('../images/dropshadow.png');
    width:972px;
    background-repeat:repeat-x;
    position: absolute;
    left: 13.5px;
    top: 228px;
    z-index: 15;
    background-color: transparent;	
    }
    
    #login{
    position: absolute;
    left: 610px;
    top: 199px;
    z-index: 20;
    color:black;
    background-color: transparent;
    border:none;
    }
    
    #login label{
    background-color:white;
    color: black;
    padding:0px;
    font-size: 13px;
    
    }
    /* Rounded Corner */
    #login input.tb5 {
    background: url('../images/rounded.png') no-repeat top left;
    height: 18px;
    padding:2px;
    background-color: white;
    border:none;	
    
    
    }
    #login inputround.tb5a {
    border: 0;
    width:220px;
    margin-top:3px;
    }

     

     

    and my html:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <link rel = "stylesheet" type="text/css" href=" styles/main_style.css" >
    </head>
    <body>
    <div id = "box">
    <div id ="header"><img src="images/header.jpg"/></div>
    <div id="menu">
    <ul>
    <li class="sel"><a href ="index.html">Index</a></li>
    <li><a href ="Forums.html">Forums</a></li>
    <li><a href ="contact.html">Contact</a></li>
    </ul>
    </div>
    <div id= "shadow"> </div>
    
    <div id="login">
    
    <form>
    <label>Username:</label> <input class="tb5" type="text" name="firstname" /><br />
    <label>Password:</label> <input class ="tb5" type="password" name="lastname" />
    </form>
    
    </div>
    </div>
    
    </body>
    </html>

     

  6. Hello, im trying to set background images using a css file but I just cant get them to show up and I have no idea why. The paths are correct ive checked that, any help is appriciated.

     

    here is my CSS:

    @CHARSET "UTF-8";
    
    * * {
    margin:0;
    padding:0;
    background-color:black;
    
    }
    
    #box {
    margin-left:auto;
    margin-right:auto;
    width: 992px;
    margin-top:none;
    }
    
    #header {
    height: 222px;
    background-image:url('..images/header.jpg');
    z-index: 5;
    }
    
    #menu {
    background-image:url('..images/menu_bar.png');
    height:100px;
    position: absolute;
    left: 0px;
    top: 190px;
    z-index: 10;
    
    }

     

     

    and here is the html:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <link rel = "stylesheet" type="text/css" href=" styles/main_style.css" >
    </head>
    <body>
    <div id = "box">
    <div id ="header"><img src="images/header.jpg"/></div>
    <div id="menu">
    <ul>
    <li>test</li>
    </ul>
    
    </div>
    
    </div>
    
    </body>
    </html>

     

     

     

  7. So im trying to figure out if a user is already in the table so im checking for the number of rows where the user id shows up on a record and if its greater then one redirect them. My problem is the if statment does not work and I know there is more then one row. Also die ($row2); wont output data but it will in a sentence (see code below for example)

    		$sql2 = "SELECT * FROM purchases WHERE nid = '$id' AND uid = '$user_id'";
    		$res2 =mysql_query($sql2) or die (mysql_error());
    		$row2 = mysql_num_rows($res2);
    
    		die($row2);//no output
    		die("There are a total of ".$row2." rows");//outputs There are a total of 20 rows
    
    		if ($row2 > 0){//if statment doesnt work.
    			//already bought the note
    			header("Location: view.php?error=2");
    		}
    

     

  8. ok, ive completly rewritten the file however if the user has bought the note already it still does not redirect them to view.php?error=2 here is my code:

     

    also:

     

    die($row2); // returns nothing

    echo ("there are a total of ".$row2. " rows"); // returns there are a total of 17 rows

     

    <?php
    require_once("models/config.php");
    
    if(isUserLoggedIn())
    	{
    		$id = mysql_real_escape_string($_GET['nid']);
    		$username = $loggedInUser->display_username;
    		$user_id = getInfoFromUsername($username);
    		$user_credits = $user_id['credits'];
    		$user_id = $user_id['User_ID'];
    
    		$sql = "SELECT * FROM notes WHERE id = '$id'";
    		$res = mysql_query($sql) or die (mysql_error());
    		$row = mysql_fetch_array($res);
    		$cost = $row['cost'];
    		$filename = $row['name'];
    
    		$sql2 = "SELECT * FROM purchases WHERE nid = '$id' AND uid = '$user_id'";
    		$res2 =mysql_query($sql2) or die (mysql_error());
    		$row2 = mysql_num_rows($res2);
    
    		if ($row2 > 0){
    			//already bought the note
    			header("Location: view.php?error=2");
    		}
    
    		if ($row['cost'] <= $user_credits){
    
    		$new_value = $user_credits - $cost;
    		$sql3 = "UPDATE userCake_Users SET credits = '$new_value' WHERE User_ID = '$user_id'";
    		$res3 = mysql_query($sql3) or die (mysql_error());
    
    		$date = time();
    		$sql4 = "INSERT INTO purchases (nid,uid,`date`) VALUES ('$id','$user_id','$date')";
    		$res4 = mysql_query($sql4) or die (mysql_error());
    		header("Location: download.php?f=".$filename);
    
    
    
    		}else{
    			//not enough credits
    			header("Location: view.php?error=3");
    
    		}
    
    
    
    	}else{
    		//not logged in
    		header("Location: view.php?error=1");
    
    	}
    
    
    ?>

     

  9. I took out the echos and die statment, but here is the full code:

     

    <?php
    require_once("models/config.php");
    
    if(isUserLoggedIn())
    	{
    		if($id = $_GET['nid']){
    
    		$sql = "SELECT * FROM notes WHERE id = ".$id;
    
    		$res = mysql_query($sql) or die (mysql_error());
    
    		while ($row = mysql_fetch_array($res)){
    
    			$noteName = $row['noteName'];
    			$name = $row['name'];
    			$cost = $row['cost'];
    
    			$user = $loggedInUser->display_username;
    
    			$sql = "SELECT * from userCake_Users WHERE Username = '$user'";
    
    			$res = mysql_query($sql) or die (mysql_error());
    
    				$user_id = getInfoFromUsername($user);
    				$user_id = $user_id['User_ID'];
    
    				$sql2 = "SELECT * FROM purchases WHERE uid =".$user_id." AND nid =".$id;
    				$res2 = mysql_query($sql2) or die (mysql_error());
    				$rows = mysql_num_rows($res2);
    				die($sql2);
    
    			while ($row = mysql_fetch_array($res)){
    				$user_id = $row['User_ID'];
    
    
    
    
    				if ($rows > 0){
    					header("Location:view.php?error=4");	
    				}
    
    				$userCredits = $row['credits'];
    				if ($userCredits >= $cost){
    					$sql = "UPDATE userCake_Users SET credits = credits -".$cost." WHERE Username ='$user'";
    					$res = mysql_query($sql) or die (mysql_error());
    
    					$date = time();
    					$sql3 = "INSERT INTO `purchases` (nid,uid,`date`) VALUES('$id','$user_id','$date')";
    					$res3 = mysql_query($sql3) or die (msyql_error());
    					$location = $name;
    					header("Location: download.php?f=".$location);
    
    
    
    				}else{
    				header("Location:view.php?error=3");	
    				}
    
    			}
    
    
    		}
    
    
    
    		}else{
    			header("Location:view.php?error=2");
    
    		}
    
    	}else{
    		header("Location:view.php?error=1");
    	}
    
    
    ?>

     

  10. Ok so when entering things into your lastupdated table i would do it like this:

     

    $date = time(); // returns somthing like 1303156571

     

    then when you query in another file to see if anything has been "last updated" on the current day you would do;

    $current_date = time();

    $sql = "SELECT * FROM top_5 WHERE lastupdated =".$current_date;

×
×
  • 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.