BloodyMind Posted October 5, 2008 Share Posted October 5, 2008 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 Quote Link to comment Share on other sites More sharing options...
ibechane Posted October 5, 2008 Share Posted October 5, 2008 That's not all of it, right? This is part of some bigger class? Because there could be something wrong elsewhere. Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted October 5, 2008 Author Share Posted October 5, 2008 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 Quote Link to comment Share on other sites More sharing options...
ibechane Posted October 5, 2008 Share Posted October 5, 2008 Well, maybe we can narrow down the possibilities. First, are you sure that $this->conn is set at the point when this code runs? Try doing this right before you run your query: print_r($this->conn); if $this->conn is set, you should see a line that tells you what kind of object that variable houses. Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted October 5, 2008 Author Share Posted October 5, 2008 I have tested it and it's set with result: mysqli Object ( ) but when i do print_r($results) it does nothing at all Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2008 Share Posted October 5, 2008 So, are you developing and testing this code on a system where error_reporting is set to at least E_ALL and display_errors is set to ON to get php to help you by showing any php detected errors? Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted October 5, 2008 Author Share Posted October 5, 2008 yes I'm making error reporting E_ALL and display_errors is set to ON but nothing happens! Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted October 5, 2008 Author Share Posted October 5, 2008 The Problem solved It was the WAMP Server was hallucinating I reinstalled it and it works just fine. Thanx for trying to help and I have an advice for anyone who donesn't know it already WAMP Server is just for learning purposes but is XAMMP good?!! Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted October 5, 2008 Author Share Posted October 5, 2008 NO IT'S NOT i've just got a little puzzled anyone please HELP Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.