ivoilic Posted March 31, 2012 Share Posted March 31, 2012 Ok so I have a form to submits to a .php file that creates an image. This works fine, but I also want the info from the form to be sent to MySQL database. The problem is that something in a script I "required" called core.inc.php is interfering and so no image is output. Here is core.inc.php: <?php ob_start(); session_start(); $current_file = $_SERVER['SCRIPT_NAME']; if(isset($_SERVER['HTTP_REFERER'])&&!empty($_SERVER['HTTP_REFERER'])) { $http_referer = $_SERVER['HTTP_REFERER']; } function loggedin() { if(isset($_SESSION['user_id'])&&!empty($_SESSION['user_id'])) { return true; } else { return false; } } function getuserfield($field) { $query="SELECT `$field` FROM `Users` WHERE `id`='".$_SESSION['user_id']."'"; if($query_run=mysql_query($query)) { if($query_result = mysql_result($query_run, 0, $field)) { return $query_result; } } } ?> Here is the code for the image creating .php file: <?php require 'connect.inc.php'; require 'core.inc.php'; $title = $_REQUEST['title'] ; $user_id = getuserfield('id'); $query = "INSERT INTO `---` VALUES ('".mysql_real_escape_string($title)."','".mysql_real_escape_string($user_id)."')"; $query_run = mysql_query($query); //There is some more code in here obviously, but it's irrelevant header('Content-type: image/png'); imagepng($image_f); imagedestroy($image_f) Can anybody give me some idea of what is conflicting or what I can do to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/260048-dynamic-image-and-data-upload-simultaneously/ Share on other sites More sharing options...
requinix Posted March 31, 2012 Share Posted March 31, 2012 It looks like there's some whitespace at the end of core.inc.php. That shouldn't be there. Easiest way to avoid that kind of problem is to just forgo the end tag. Leave it out. It's not like it's necessary. Quote Link to comment https://forums.phpfreaks.com/topic/260048-dynamic-image-and-data-upload-simultaneously/#findComment-1332936 Share on other sites More sharing options...
ivoilic Posted March 31, 2012 Author Share Posted March 31, 2012 sorry i'm pretty new at this can you clarify Quote Link to comment https://forums.phpfreaks.com/topic/260048-dynamic-image-and-data-upload-simultaneously/#findComment-1332941 Share on other sites More sharing options...
requinix Posted March 31, 2012 Share Posted March 31, 2012 At the very end. ?> Try removing the ?> entirely. Quote Link to comment https://forums.phpfreaks.com/topic/260048-dynamic-image-and-data-upload-simultaneously/#findComment-1332957 Share on other sites More sharing options...
ivoilic Posted March 31, 2012 Author Share Posted March 31, 2012 YES it worked! Thanks so much. If it's not to much trouble can you tell me why that actually worked. Quote Link to comment https://forums.phpfreaks.com/topic/260048-dynamic-image-and-data-upload-simultaneously/#findComment-1333003 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.