floridaflatlander Posted March 18, 2011 Share Posted March 18, 2011 I have worked on this for hours and can't find the problem. My $r doesn't query for some reason I've tested the database connection and variables with echo statements and they work, also there is an SELECT statement above this that checks to see if the name is in use and it works like it is suppose to. I just can't get this code to work. I have php5, the database connection with host, user, pw and database name are correct and isn't redefined or exited. The SELECT I mentioned uses the same connection. Can any one see whats wrong with this $q = "INSERT INTO vendors (id_vendor, name, s_discrip, discript, phone, zip, id_loca, email, web_title, web_url, photo, date_reg) VALUES (NULL, '$name', '$s_discrip', '$discrip', '$phone', '$zip', '$loca', '$email', '$ws_title', '$ws_url', 'photo', CURRENT_TIMESTAMP);"; $r = mysqli_query($dbc, $q); Thanks S Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 18, 2011 Share Posted March 18, 2011 How about using mysqli_error($dbc) to get php/mysql to tell you why the query is failing? Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189304 Share on other sites More sharing options...
Maq Posted March 18, 2011 Share Posted March 18, 2011 If I had to take a wild guess, it would be that one of your fields is an integer and you're passing in a string. Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189309 Share on other sites More sharing options...
PFMaBiSmAd Posted March 18, 2011 Share Posted March 18, 2011 Un-escaped data? Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189311 Share on other sites More sharing options...
floridaflatlander Posted March 18, 2011 Author Share Posted March 18, 2011 I use mysqli_connect_error() , all tables are in the same database as the location table that fills out a drop down menu to get $loca and that works so I have a db connection. I only have two integer columns. One is auto_increment and the other is a number representing the location Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189326 Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2011 Share Posted March 18, 2011 I use mysqli_connect_error() , Really? Where? It isn't in the code you posted. Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189329 Share on other sites More sharing options...
floridaflatlander Posted March 18, 2011 Author Share Posted March 18, 2011 The mysqli_connect_error() comes in in an include statement before the queries, DB_HOST etc. are defined with define statments. $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die('Could not connect to MySQL;'. mysqli_connect_error()); if (!$dbc){ trigger_error('Could not connect to Mysql: ' . mysqli_connect_error()); } Also would think all is OK since I use two selects on the form that enters the info, one to check for user name the other to get location IDs Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189331 Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2011 Share Posted March 18, 2011 Oh, not mysqli_connect_error(), mysqli_error(). The latter is used to report errors in query executions. if( !$result = mysqli_query($dbc, $query) ) { echo "<br>Query string: $query<br>Resulted in error: " . mysqli_error($dbc) . '<br>'; } Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189333 Share on other sites More sharing options...
floridaflatlander Posted March 18, 2011 Author Share Posted March 18, 2011 Duh, this is embarrassing, I spent all afternoon looking at this stuff. The column name for the description is descrip not discript. Thanks to all for the help. I can't say it enough. S Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189349 Share on other sites More sharing options...
Pikachu2000 Posted March 18, 2011 Share Posted March 18, 2011 We've all done something like that, no biggie. Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189352 Share on other sites More sharing options...
DavidAM Posted March 19, 2011 Share Posted March 19, 2011 We've all done something like that, no biggie. NOT ME!! Well ... not today at least. --- OK, actually, not since lunch. Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1189366 Share on other sites More sharing options...
Maq Posted March 21, 2011 Share Posted March 21, 2011 We've all done something like that, no biggie. NOT ME!! Well ... not today at least. --- OK, actually, not since lunch. Quote Link to comment https://forums.phpfreaks.com/topic/231034-problem-with-insert-query/#findComment-1190263 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.