jamesxg1 Posted April 11, 2009 Share Posted April 11, 2009 <?php session_start(); ini_set('display_errors', 1); error_reporting(E_ALL); include 'Database/Connection.php'; include 'Database/Utility.php'; CheckFolder(); isloggedin(); accessneeded("C"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Admin Page</title> <script type="text/javascript" src="CoreFiles/JS/CalendarDateInput.js"></script> </head> </html> <?php if (isset($_POST['Image'])) { function get_code($seed_length= { $seed = "234567892345678923456789"; $str = ''; srand((double)microtime()*1000000); for ($i=0;$i<$seed_length;$i++) { $str .= substr ($seed, rand() % 48, 1); } return $str; } $unique = false; do { $cap_code = get_code(); $query = "SELECT `userid` FROM `members` WHERE userid = '$cap_code'" or die(mysql_error()); $sql = mysql_query($query); if(mysql_num_rows($sql) == 0) { $unique = true; } } while(!$unique); define ("MAX_SIZE","100"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; $image = $_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif") && ($extension != "bmp")) { echo '<h1>Unknown extension!</h1>'; exit(); } else { $size = filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; exit(); } $userid = $_SESSION['userid']; $newid = get_code(); $image_name = "$userid _$newid _$filename"; $newname="User_files/$userid/Images/".$image_name; $whoto = mysql_real_escape_string($_POST['whoto']); $date = mysql_real_escape_string($_POST['whoto']); $useridt = mysql_real_escape_string($_SESSION['userid']); $alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $rand = substr(str_shuffle($alphanum), 0, 16); $username = $rand; $password = $rand; $sql = "INSERT INTO `unlock` (username, password, medianame, format, owner, whoto, when) VALUES('$username', '$password', 'get_code()', 'Image', '$useridt', $whoto', '$date')" or die(mysql_error()); mysql_query($sql); $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { print "<P ALIGN=CENTER><strong><font color='red'>The Photo $filename Was Unable To Upload, Please Try Again.</font></P>"; exit(); } } } if(isset($_POST['Image']) && !$errors) { print "<P ALIGN=CENTER><strong><font color='green'>The Photo $filename Was Uploaded Sucessfully!</font></P>"; } } if(@$_GET['upload'] == "image") { $userid = $_SESSION['userid']; { ?> <form enctype="multipart/form-data" action="<?php $PHP_SELF ?>" method="POST"> <table> <tr><td>Please choose a image: <br /><input type="file" name="image"></td></tr> <tr><td>Who Is This For: <br /> <?php $query = "SELECT * FROM `contacts` WHERE holder = '$userid'" or die(mysql_error()); $result = mysql_query($query); echo "<select name='whoto' value=''>"; while($nt=mysql_fetch_array($result)){ echo "<option value='$nt[secid]'>$nt[firstname] $nt[lastname]</option>"; } echo "</select>"; ?> </select></tr></td> <tr><td>Select The Date This File Will Become Avalible:<br><script>DateInput('fromdate', true, 'DD-MON-YYYY')</script></td></tr> <tr><td><input name='Image' type='submit' value='Submit'></td></tr> </table> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/153637-solved-wont-insert-into-mysql-s/ Share on other sites More sharing options...
PHP Monkeh Posted April 11, 2009 Share Posted April 11, 2009 Change: mysql_query($sql); to: mysql_query($sql) or die(mysql_error()); It'll tell you why Link to comment https://forums.phpfreaks.com/topic/153637-solved-wont-insert-into-mysql-s/#findComment-807323 Share on other sites More sharing options...
jamesxg1 Posted April 11, 2009 Author Share Posted April 11, 2009 Change: mysql_query($sql); to: mysql_query($sql) or die(mysql_error()); It'll tell you why got it working, thanks man your a god send!. Link to comment https://forums.phpfreaks.com/topic/153637-solved-wont-insert-into-mysql-s/#findComment-807329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.