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 Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/ 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. Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/#findComment-657427 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 Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/#findComment-657434 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. Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/#findComment-657438 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 Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/#findComment-657460 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? Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/#findComment-657462 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! Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/#findComment-657483 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?!! Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/#findComment-657532 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 Link to comment https://forums.phpfreaks.com/topic/127097-cannot-execute-query-in-php-executes-in-phpmyadmin/#findComment-657535 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.