Jump to content

BloodyMind

Members
  • Posts

    98
  • Joined

  • Last visited

    Never

Posts posted by BloodyMind

  1. this is just a part of a function in a class

    but i just put the part with the bug just not to confuse you with alot of code!

    if you'd like me to paste all the class it's okay but i use this function solely it just used the file handle static method that returns the uploaded file and i have no problem with it

     

    the point is that I execute this query in PhpMyAdmin and it works and not working on the script itself !!

     

    I've copied and pasted this query from php and pasted it in phpMyAdmin and it works

     

    I'm losing my mind seriously

     

    and I have rewritten it in several methods including spritntf(), heredoc and concatenation of vars and nothing is happening but catching this exception

     

     

     

  2. Hi there,

    I've tried this script for uploading and inserting projects details in the database

    but this query doesn't work as u see i've tried all kinds of methods to write a query into php

    I also echo the query and copy and paste it in PHPMyAdmin and it executes there perfectly

    but it doesn't wanna work on php

    if anyone got help please reply me ASAP

     

    <?php
    public function addProject($in_projectName,$in_projectDesc){
    	try {
    
    //			$user_id = $_SESSION['user_id'];
    		$user_id = '1';
    
    		// get filename here
    		$projectsDir = 'c:/wamp/www/computek/projects/';
    
    		$filename = Handles::uploadHandle('projectFile',$projectsDir,'Cannot upload Project.');
    
    		$parts = explode('/computek',$filename);
    		$filename = $parts[1];
    		// verify the zip file
    		if (substr($filename,-4,4)!=='.zip') {
    			throw new Exception('We can only accept ZIP file format.');
    		}
    		$filename = urlencode($filename);
    		echo $in_projectName;
    		echo "<br/>";
    		$prosql = <<<EOP
    INSERT INTO projects(pro_title,pro_file,user_id) VALUES('$in_projectName','$filename','$user_id')
    EOP;
    		echo $filename;
    		echo "<br/>";
    		/*
    		$prosql = sprintf("INSERT INTO projects(pro_id, pro_title,pro_filename,user_id)
    		 VALUES('NULL','%s', '%s', '%d')",$in_projectName,$filename,$user_id);*/
    		// insert project's details into the projects table
    		/*$prosql = "INSERT INTO projects(pro_title,pro_filename,user_id)
    		 VALUES('" . $in_projectName . "', '" . $filename . "', '" . $user_id . "');";*/
    /*			$prosql = <<<EOPRO
    INSERT INTO projects SET pro_title='{$in_projectName}',pro_filename='{$filename}',user_id='{$user_id}';
    EOPRO;*/
    		echo $prosql;
    		echo "<br>";
    		$results = $this->conn->query($prosql);
    		if ($results == FALSE) {
    			throw new Exception('Cannot Execute Project Query');
    		}
    }
    ?>

     

    Thank you in Advance

  3. Hey there,

    I got a problem with the file upload in an advanced contact form which have attachments for Resume and such

     

    my problem is when i upload the file

    I get this Error:

     

    Warning: move_uploaded_file(/home/xxx/public_html/test/attachments/) [function.move-uploaded-file]: failed to open stream: Is a directory in /home/xxx/public_html/test/contact.php on line 13

     

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpaOoPbE' to '/home/xxx/public_html/test/attachments/' in /home/xxx/public_html/test/contact.php on line 13

     

    and i have the permission to attachments to '777'

     

    does anyone got a clue?

    thanx in advance for your support

  4. It's a simple select query as u see nothing is wrong with it

     

    and I didn't get u ionik actually I was trying to separate queries in a class so i can modify it easily later but i think i'll change this strategy now

    and do it as i used to

     

  5. <?php
    
    public function getUserLogin($in_username){
    	$this->query = <<<EOQUERY
    SELECT * FROM users WHERE username = '$in_username';
    EOQUERY;
    	$result = $this->db->query($this->query);
    	try {
    		if($result == FALSE){
    			throw new Exception('Error:Cannot execute check query');
    		}
    
    	}catch (Exception $e){
    		echo $e->getMessage();
    	}
    	if (is_object($result) == false) {
    		echo "not object";
    	}
    	return $result;
    }
    
    
    // here is where the function call gets the error
    
    private function confirmUserNamePasswd($in_user_name, $in_user_password,$in_db_conn = NULL){
    
    	/*
    	- internal arg checking
    	- get a connection
    	- get the record for the username.
    	- verify the password
    	*/
    	if ($in_db_conn == NULL) {
    		$conn = $this->getConnection();
    	}else {
    		$conn = $in_db_conn;
    	}
    
    
    	try {
    
    
    		// 2. make sure incoming username is safe for queries.
    		$user_name = $this->super_escape_string($in_user_name,$conn);
    
    		// 3. get the record with this username
    
    		if (!is_object($DA)) {
        		$DA = new usersDataAccess();
        	        }
        	
        	        // here Supposed to return the object
    
    		$results = $DA->getUserLogin($user_name);
    
    		if ($results = FALSE) {
    			throw new DatabaseErrorException($conn->Error);
    		}
    		// 4. re-confirm the name and the passwords match
    		$login_ok = FALSE;
    
    		// here when i try to use the passed $results I get the error
    
    		while ($row = $results->fetch_assoc() !== NULL) {
    			if (strcasecmp($row['username'],$user_name) == 0) {
    				// good, name matched.  does password?
    				if (strcasecmp(md5($in_user_password),$row['password']) == 0) {
    					$login_ok = TRUE;
    					$user_id = $row['user_id'];
    				}else {
    					$login_ok = FALSE;
    				}
    				break;
    			}
    		}
    
    		$results->close();
    
    	}catch (Exception $e){
    		if (isset($conn) and $in_db_conn === NULL) {
    			$conn->close();
    		}
    		throw $e;
    	}
    
    	// only clean up what we allocated
    	// if there wasn't a db con we close it to clean
    	if ($in_db_conn === NULL) {
    		$conn->close();
    	}
    	// throw on failure, or return the user ID on success
    	if ($login_ok == FALSE) {
    		throw new Exception('Invalid username/password');
    	}
    	return $user_id;
    
    }
    
    
    
    

     

    The Error

     

    Fatal error: Call to a member function fetch_assoc() on a non-object in C:\wamp\www\computek\bizlogic\userManager.php on line 334
  6. well actually It's coz of permissions I use windows XP

    and then if i edit the attributes of the file and uncheck the Read Only

    then when i try to access it again I find read only checked

     

    it's something with the apache I guess but I don't think the allow_url_fopen is a good idea

     

    I solved it by disabling an apache extention which was authz_file or something like that i can't remember

    but i'm not sure i'm doing the right solution.

     

    and I still find the same issue with directories when i try to write a new file to a directory i always find it read only when i uncheck it I find it read only again :S

     

    Thanx guys for trying to help

  7. thanx alot KeeB

    I've been stuck of thinking of procedural programming

    like bottom up planning and it was hard

    but finally my latest method of planning

    is to write the abstract functions of the system to subsystems

    then break them down to classes

    but this way seems better thanx again for the info

  8. yes you made the function but you didn't call it and yes use if statement

    and btw you got syntax errors better use a debugger like Zend Studio or PHP Designer

     

    for example you should write something like this

    if(checkmail($_POST['email']) !== FALSE && checkForm($name,$lname,$subject,$email,message) !== FALSE)){
          mail($to, $subject, $message, $email);
    }else{
          echo "Please fill in all fields correctly";
    }
    

     

     

  9. When I instantiate it like this:

    $dom = new DOMDocument();

     

    I get this warning:

     

    domdocument::domdocument() expects at least 1 parameter, 0 given

     

    if I instantiate it like this

     

    $dom = new DOMDocument('1.0', 'utf-8');

     

    I get this warning:

    Warning: domdocument::domdocument() expects parameter 2 to be long

    Then after both warnings I get this fatal error too:

     

    Fatal error: Call to undefined method domdocument::load()

     

    What shall I do?

    Is that the domxml extention is hallucinating ?

     

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