ajicles Posted July 28, 2010 Share Posted July 28, 2010 So for some reason when I put mysql close inside of a function if give me a santax error in DreamWeaver CS5 and with the mysql close isn't inside of the function its fine.. All I am trying to do it if the user get the captcha wrong it will not do the function. $captcha = rand(1,10); if(isset($_POST['MultiPowUpload_browserCookie'])) { $cookies = split(";", $_POST['MultiPowUpload_browserCookie']); foreach($cookies as $value) { $namevalcookies = split("=", $value); $browsercookie[trim($namevalcookies[0])] = trim($namevalcookies[1]); } $_COOKIE = $browsercookie; } //restore session if possible if(isset($browsercookie) && isset($browsercookie['PHPSESSID'])) { session_id($browsercookie['PHPSESSID']); session_start(); } if (isset($_POST['submit'])) {} function upload_form(){ $uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/UploadedFiles/"; if(count($_FILES) > 0) { $arrfile = pos($_FILES); $uploadfile = $uploaddir . basename($arrfile['name']); $filename = basename($arrfile['name']); if (move_uploaded_file($arrfile['tmp_name'], $uploadfile)) echo "File " . basename($arrfile['name']) . " was successfully uploaded."; //$filename = basename($arrfile['name']; } echo '<br> '; // At least one symbol should be sent to response!!! $ip_address = $_SERVER['REMOTE_ADDR']; $file_hash = hash('ripemd160', '$filename'); echo 'Link to your file: <a href="http://localhost/filehosting/?d='.$file_hash.'">http://localhost/filehosting/?d='.$file_hash.'</a>'; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("filehosting"); $sql="INSERT INTO data(ID, file_location, file_hash, file_ip_address) VALUES ('','$filename','$file_hash','$ip_address')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } } mysql_close($con) And this doesn't work: if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con) } Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 28, 2010 Share Posted July 28, 2010 ; Quote Link to comment Share on other sites More sharing options...
radar Posted July 28, 2010 Share Posted July 28, 2010 Abra is correct, you are missing the smallest, but most often missed piece of syntax there is. add a ; after t he mysql_close, and it shall work for you. Quote Link to comment Share on other sites More sharing options...
ajicles Posted July 29, 2010 Author Share Posted July 29, 2010 Ahah I such an idiot lol. 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.