jasonhardwick Posted May 6, 2008 Share Posted May 6, 2008 For some reason my code produces no results can anyone see what i'm missing? <? session_start(); if (empty($_SESSION['username'])){ header("location:index1.php"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="realitysoftware.ca" /> <title>My Creative Process Links - Post New Creative</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <style type="text/css"> <!-- .style1 { color: #f73602; font-weight: bold; } --> </style> </head> <body> <div id="main"> <div id="navbar"></div> <div id="header"> <div id="left_bar_header"><span class="title_dark">MY CREATIVE </span> <span class="title"> PROCESS </span> <p>This site was developed as a link for the creative community. It is an area where we can come to get feed back on our ideas and designs. A great designer never forgets that everyone needs a second opinion sometimes.</p> </div> <div id="right_bar_header"><img src="images/head_bckg_right.jpg" alt="" /></div> </div> <div id="content"> <table width="95%" border="0" align="center" cellpadding="5"> <tr> <td><a href="/index.php">home</a> | <a href="/main_forum.php">review</a> | <a href="/create_topic.php">post</a> | <a href="/mindgames.php">mindgames</a> | <a href="/archive.php">archive</a> | <a href="/brainstorm.php">brainstorm</a> | <a href="/my_account.php">my account</a> | <a href="/suggestion_box.php">suggestion box</a></td> <td><div align="right"><a href="/login.php">login</a></div></td> </tr> </table> <table width="95%" border="0" align="center"> <tr> <td height="0" valign="top"><h1><span class="red">Post </span> Creative</h1></td> <td valign="top"> </td> <td valign="top"> </td> <td width="180" rowspan="4" valign="top"><div align="right"> <p class="style1">Sponsored Links</p> <p><a href="/links/schools.php" target="_blank">Creative Schools</a></p> <p><a href="/links/careers.php" target="_blank">Creative Careers</a></p> <p><a href="/links/publications.php" target="_blank">Creative Publications</a></p> <p><a href="/links/professionals.php" target="_blank">Creative Professionals</a></p> <p><a href="/links/creative.php" target="_blank">General Creative Links</a></p> <p><a href="/links/photography.php" target="_blank">Photography Links</a></p> <p><a href="/links/art.php" target="_blank">Art Links</a></p> <p><a href="/links/design.php" target="_blank">Design links</a></p> <p><a href="/links/illustration.php" target="_blank">Illustration Links</a></p> <p><a href="/links/web.php" target="_blank">Web Links</a></p> <p><a href="/links/3d.php" target="_blank">3D Design Links</a></p> <p><a href="/links/id.php" target="_blank">Interior Design Links</a></p> </div></td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top"><? echo $_SESSION['username'];?></td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top"><p> </p> <?php include "config.php"; $file_name = $HTTP_POST_FILES['ufile']['name']; $random_digit=uniqid("file_"); $new_file_name=$random_digit.$file_name; $path= "file/".$new_file_name; $tbl_name="forum_question"; $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $email=$_POST['email']; $file=$_POST['file']; $file_type=$_POST['file_type']; $username=$_POST['username']; $datetime=date("d/m/y h:i:s"); //create date time $sql="INSERT INTO $tbl_name(username, topic, detail, name, email, file, file_type, datetime)VALUES('$username', '$topic', '$detail', '$name', '$email', '$new_file_name', '$file_type', '$datetime')"; if($result) { echo "hello"; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "Successful<BR/>"; echo "<a href=main_forum.php>View your topic</a>"; echo "File Name :".$new_file_name."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>"; } else { echo "Error"; } } } ?> </td> <td valign="top"></td> <td valign="top"></td> </tr> </table> <p></p> <p> </p> <div id="content"> <div class="secondary_page_first_column" id="secondary_page_first_column"></div> </div> </div></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/104448-php-that-doesnt-work/ Share on other sites More sharing options...
budimir Posted May 6, 2008 Share Posted May 6, 2008 You are not executing your sql query! Try: $exec = mysql_query($sql) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/104448-php-that-doesnt-work/#findComment-534650 Share on other sites More sharing options...
rhodesa Posted May 6, 2008 Share Posted May 6, 2008 following the variables you use, it would be: $result = mysql_query($sql) or die (mysql_error()); and it would go right after this line: $sql="INSERT INTO $tbl_name(username, topic, detail, name, email, file, file_type, datetime)VALUES('$username', '$topic', '$detail', '$name', '$email', '$new_file_name', '$file_type', '$datetime')"; Quote Link to comment https://forums.phpfreaks.com/topic/104448-php-that-doesnt-work/#findComment-534653 Share on other sites More sharing options...
jasonhardwick Posted May 6, 2008 Author Share Posted May 6, 2008 ok... now i'm getting an "ERROR", It puts the info in my sql but gives me an error. any ideas why that would happen? Also my file isn't uploading to my "file" folder Quote Link to comment https://forums.phpfreaks.com/topic/104448-php-that-doesnt-work/#findComment-534674 Share on other sites More sharing options...
jasonhardwick Posted May 6, 2008 Author Share Posted May 6, 2008 I think i'm loosing the file extension when i look at the sql field i only see the name and no ext... what would cause that? Quote Link to comment https://forums.phpfreaks.com/topic/104448-php-that-doesnt-work/#findComment-534702 Share on other sites More sharing options...
robos99 Posted May 6, 2008 Share Posted May 6, 2008 If you're getting the variable $_POST['file'] from a file upload, I beleive that only contains a pointer to the file, and not the actual file name. Double check the PHP manual on this, but I think you need to pull the file name from the $_FILES variable. Quote Link to comment https://forums.phpfreaks.com/topic/104448-php-that-doesnt-work/#findComment-534734 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.