mtesm Posted November 4, 2008 Share Posted November 4, 2008 Well im trying to make it so users input strings into a form and it sends it and the time and their username they're logged in as to mySQL database and i keep getting the same error which is confusing because i cant see the problem >_< <h1>Submit Data</h1> <?php //include("include/session.php"); if($session->logged_in){ echo "<form name='submitdata' methord='post' action='submit.php'>"; echo "World: <br> <input type='text' name='world'/><br>"; echo "Category:<br><input type='text' name='category'/><br>"; echo "Name:<br> <input type='text' name='name'/><br>"; echo "Price:<br><input type='text' name='price'/><br>"; echo "<input type='submit' value='Submit Data' />"; echo "</form>"; if (isset ($_POST['name'])) { $price = $_POST['price']; $name = $_POST['name']; $category = $_POST['category']; $world = $_POST['world']; $time_now = date('mdy'); $human_now = date('l jS \of F Y h:i:s A'); //Lets connect to the database $connection = mysql_connect ("localhost","x","x") or die ("Cannot connect to db"); //then select the database that we are using. mysql_select_db("price_list",$connection); //now the SQL INSERT [ These are the table names] [and here are the values going into those tables] $SQL = "INSERT into item (time,world,category,name,price) VALUES ('".$time_now."','".$world."','".$category."',,'".$name."',,'".$price."')"; // Send our SQL $result = mysql_query($SQL,$connection) or die (mysql_error()); echo "DATA SENT<br>"; echo "=========<br>"; echo $time_now. "<br>"; echo $human_now. "<br>"; echo $session->username. "<br>"; echo $world. "<br>"; echo $category. "<br>"; echo $name. "<br>"; echo $price. "<br>"; } } else{ echo "Hello <b>$session->username</b>, this is a page where users can submit data, so we please <a href=\"account.php\">login</a> to view this page. Not registered? <a href=\"register.php\">Sign-Up</a>"; } ?> the session.php is included on the page that includes this into it. and this is included in submit.php Link to comment https://forums.phpfreaks.com/topic/131286-sending-to-mysql-via-form-help-_/ Share on other sites More sharing options...
trq Posted November 4, 2008 Share Posted November 4, 2008 What is this error you keep getting? Link to comment https://forums.phpfreaks.com/topic/131286-sending-to-mysql-via-form-help-_/#findComment-681670 Share on other sites More sharing options...
mtesm Posted November 4, 2008 Author Share Posted November 4, 2008 err well when i was messing around it had an error but it doesn't seem to anymore it just doesn't send anything to my database.. or display on the screen that it sent but when i got the error it was on line 26 and with something about a t_variable Link to comment https://forums.phpfreaks.com/topic/131286-sending-to-mysql-via-form-help-_/#findComment-681674 Share on other sites More sharing options...
mtesm Posted November 4, 2008 Author Share Posted November 4, 2008 but if i take away the isset and the query it says DATA SENT ========= 110308 Monday 3rd of November 2008 07:28:03 PM Admin which means its not getting the form variables properly :S Link to comment https://forums.phpfreaks.com/topic/131286-sending-to-mysql-via-form-help-_/#findComment-681676 Share on other sites More sharing options...
AndyB Posted November 4, 2008 Share Posted November 4, 2008 $SQL = "INSERT into item (time,world,category,name,price) VALUES ('".$time_now."','".$world."','".$category."',,'".$name."',,'".$price."')"; If I had to guess, I'd say those ,, ought to be just one comma. Link to comment https://forums.phpfreaks.com/topic/131286-sending-to-mysql-via-form-help-_/#findComment-681700 Share on other sites More sharing options...
mtesm Posted November 4, 2008 Author Share Posted November 4, 2008 yea i fixed that and its still not doing anything with the form Link to comment https://forums.phpfreaks.com/topic/131286-sending-to-mysql-via-form-help-_/#findComment-681701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.