emediastudios Posted November 10, 2007 Share Posted November 10, 2007 I have this problem where, on my pc at home with apache and sql, when testing my site on my home pc with apache and sql, everything is fine, but when i posted it on the net, none of the add records work, the files get sent, but no record inserted in my database. Strange.. Anyone got an idea? <?php //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES (NULL,'$name', '$rank', '$suburb', '$price', '$content', '$content2','$agentmobile', '$agentemail','$uploadFile0','$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')"); ?> All my inserts are similar to above Thanks anyone Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 you should check if your getting connected properly to the correct server/database, also check for mysql errors while inserting Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 Site is dynamic and most content is drawn from a database so i fairly sure the connection is good, and i get no reported errors. Goes to the success page every time. Do i need a (restrict access to page() ) on my process files? based on username and password? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 try this for one of your statements <?php //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES (NULL,'$name', '$rank', '$suburb', '$price', '$content', '$content2','$agentmobile', '$agentemail','$uploadFile0','$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')") or die "Error: ".mysql_error(); ?> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 Get this error with your code Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\Program Files\Apache Group\Apache2\htdocs\gcproperty\admin\add_test.php on line 167 Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 This is my ful code, works on my localhost, not when posed on the net. <?php //***FUNCTIONS //filter extensions function valid_ext($file_name) { $valid = array("jpeg","jpg","png","gif"); $extension = strtolower(substr($file_name,-3,3)); return (in_array($extension, $valid)); } //filter by size, function valid_size($size) { return ($size <= 1048576); } //This is the directory where images will be saved $path = '../images/'; //This gets all the other information from the form $name=$_POST['name']; $rank=$_POST['rank']; $suburb=$_POST['suburb']; $price=$_POST['price']; $content=$_POST['content']; $content2=$_POST['content2']; $agentmobile=$_POST['agentmobile']; $agentemail=$_POST['agentemail']; $uploadFile0=($_FILES['uploadFile0']['name']); $uploadFile1=($_FILES['uploadFile1']['name']); $uploadFile2=($_FILES['uploadFile2']['name']); $uploadFile3=($_FILES['uploadFile3']['name']); $uploadFile4=($_FILES['uploadFile4']['name']); $uploadFile5=($_FILES['uploadFile5']['name']); $uploadFile6=($_FILES['uploadFile6']['name']); $uploadFile7=($_FILES['uploadFile7']['name']); $uploadFile8=($_FILES['uploadFile8']['name']); // Uploads Images $uploadNeed = $_POST['uploadNeed']; // start for loop $copied = 0;//the number of files successfully uploaded for($x=0;$x<$uploadNeed;$x++) { $file_name = $_FILES['uploadFile'. $x]['name']; //test $Size = $_FILES['uploadFile'. $x]['size']; //Test Check $Valid = false; if(valid_ext($file_name)) { echo " {$file_name} valid ext"; $Valid = true; }else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=invalid_extension.php\">"; exit(); } echo "</br>"; if(valid_size($Size)) { echo " {$file_name} valid size</br>"; }else{ $Valid = false; print "<meta http-equiv=\"refresh\" content=\"0;URL=invalid_size.php\">"; exit(); } if($Valid) { // strip file_name of slashes $file_name = stripslashes($file_name); $file_name = str_replace("'","",$file_name); if(file_exists($path . $file_name) ) { print "<meta http-equiv=\"refresh\" content=\"0;URL=file_exists.php\">"; exit(); }else { $copy = move_uploaded_file($_FILES['uploadFile'. $x]['tmp_name'], $path . $file_name); $copied++;//increment our counter } } } if($copied > 0) { //do your insert stuff if($copied != $uploadNeed) { $not_uploaded = $uploadNeed - $copied; print "<meta http-equiv=\"refresh\" content=\"0;URL=upload_error.php\">"; exit(); } } // check if successfully copied if($copied == $uploadNeed) { print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">"; //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES (NULL,'$name', '$rank', '$suburb', '$price', '$content', '$content2','$agentmobile', '$agentemail','$uploadFile0','$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')"); }else{ echo "<br>$file_name The File(s) could not be uploaded!<br>The file must be under 1 meg and be of a valid extension type, jpeg, jpg, png or gif!<br /> <br /> Please go <a href=\"property_add.php\">back</a> and try again"; } // end of loop ?> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 I have this connection on the 1st line of my page <?php require_once('../Connections/gcproperty.php'); ?> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 All my update record files work, my delete records too, just not my insert record, could it have something to do with the fact that all my insert records post the info to a php proccessing file? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 don't know what could be wrong try this if($copied == $uploadNeed) { //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES (NULL,'$name', '$rank', '$suburb', '$price', '$content', '$content2','$agentmobile', '$agentemail','$uploadFile0','$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')"); print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">"; }else{ echo "<br>$file_name The File(s) could not be uploaded!<br>The file must be under 1 meg and be of a valid extension type, jpeg, jpg, png or gif!<br /> <br /> Please go <a href=\"property_add.php\">back</a> and try again"; } } Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 No good either ??? Tried something similar before and had no luck ??? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 is it getting redirected to the property_added_successfully.php ? Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 yes Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 and all the images get uploaded, i can see them in the directory ??? ??? Everything works but the insert record. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 try this mysql_query("INSERT INTO `employees` VALUES (NULL,'$name', '$rank', '$suburb', '$price', '$content', '$content2','$agentmobile', '$agentemail','$uploadFile0','$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')"); if (mysql_error()) { print "there was an error -- ".mysql_error();; } and remove the meta-refresh for the moment Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 Your onto something. there was an error -- No database selected Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 hmm.. check your connection settings in your connection file see if the right database is getting selected Quote Link to comment Share on other sites More sharing options...
emediastudios Posted November 10, 2007 Author Share Posted November 10, 2007 Used this code <?php //Writes the information to the database $dbuser="emediast"; $dbpass="7833pjer"; $dbname="emediast_gcproperty"; //the name of the database $chandle = mysql_connect("localhost", $dbuser, $dbpass) or die("Connection Failure to Database"); echo "Connected to database server<br>"; mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found." . $dbuser); echo "Database " . $database . " is selected"; mysql_query("INSERT INTO `employees` VALUES (NULL,'$name', '$rank', '$suburb', '$price', '$content','$content2','$agentmobile', '$agentemail','$uploadFile0','$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')"); mysql_close($chandle); ?> and i get this error angelina_jolie_11_r2_c1_jpg.jpg valid ext angelina_jolie_11_r2_c1_jpg.jpg valid size Connected to database server Database is selected Warning: mysql_query() [function.mysql-query]: Access denied for user 'emediast'@'localhost' (using password: NO) in /home/emediast/public_html/gcproperty/admin/add_test.php on line 168 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/emediast/public_html/gcproperty/admin/add_test.php on line 168 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.