ajetrumpet Posted October 7, 2010 Share Posted October 7, 2010 could someone help me with this. here is what I have: <?php require_once('dbinfo.php'); ?> <?php mysql_connect($dbaddress,$username,$password); mysql_select_db($db) or die("Cannot find database!"); /* $query = "SELECT * FROM contacts"; $result = mysql_query($query); $numRows = mysql_numrows($result); $i = 0; while ($i < $numRows) { echo mysql_result($result, $i, "first") . " " . mysql_result($result, $i, "last"); $i++; } */ $fname = 'WrdScramble()'; $ftype = 'DAO'; $fdesc = 'Randomly rearranges the characters in a string or word.'; $fcode = ''; $query = "INSERT INTO functions VALUES ('','$fname','$fcode','$ftype','$fdesc')"; mysql_query($query); print($query); //$query = "SELECT fcode FROM contacts WHERE first = 'code'"; //$result = mysql_query($query); //$numRows = mysql_numrows($result); //$fcode = mysql_result($result, 0, "fcode"); ?> <? //close connection mysql_close(); ?> It is not inserting the data into the database, and if I use: mysql_error() and print it out, I get nothing with that either. I am not sure where to go! I also have used this: (fid, fname, fcode, ftype, fdesc) preceeding the 'VALUES' word in the statement just to see if it would take. No luck! Do I not see the obvious? Any help appreciated! thanks! (I have checked my field types and max length in PHPmyadmin and they are not an issue.) Quote Link to comment https://forums.phpfreaks.com/topic/215355-insert-into-trouble/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2010 Share Posted October 7, 2010 HOW are you using mysql_error()? You would need to echo it to see any error it returned. What output or symptom are you getting when you request the page? Have you successfully executing any mysql_query() statement on the server? Quote Link to comment https://forums.phpfreaks.com/topic/215355-insert-into-trouble/#findComment-1119875 Share on other sites More sharing options...
ajetrumpet Posted October 7, 2010 Author Share Posted October 7, 2010 yes I have. the first one I put in was successful and it was the first and only one I did. the syntax I used was the same too. this is what I have inserted at the end of the page: if (!$query) {echo(mysql_error());} I am getting a blank page. NOTHING else. which is what I am supposed to see really, unless there is an error. thank you! Quote Link to comment https://forums.phpfreaks.com/topic/215355-insert-into-trouble/#findComment-1119879 Share on other sites More sharing options...
mikosiko Posted October 7, 2010 Share Posted October 7, 2010 comment this line mysql_query($query) ; and take a look what are you getting in your $query variable... your print($query) will show you. Quote Link to comment https://forums.phpfreaks.com/topic/215355-insert-into-trouble/#findComment-1119880 Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2010 Share Posted October 7, 2010 In the main code you posted, $query is the query string and it is set, so your conditional code you just posted will always be false and will never echo mysql_error(). Quote Link to comment https://forums.phpfreaks.com/topic/215355-insert-into-trouble/#findComment-1119884 Share on other sites More sharing options...
ajetrumpet Posted October 7, 2010 Author Share Posted October 7, 2010 this is what I get: INSERT INTO functions VALUES ('','WrdScramble()','','DAO','Randomly rearranges the characters in a string or word.') I don't see any exceptions. do you? Quote Link to comment https://forums.phpfreaks.com/topic/215355-insert-into-trouble/#findComment-1119900 Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2010 Share Posted October 7, 2010 How would anyone here be able to tell you if that query is correct or not. You are the only one here who knows what your table definition is. And that's not a suggestion to post you table definition. It's a suggestion for you to troubleshoot what your code and query are doing on your server and with your database. Fix your code that is using mysql_error() and it will tell you why the query is failing. Quote Link to comment https://forums.phpfreaks.com/topic/215355-insert-into-trouble/#findComment-1119906 Share on other sites More sharing options...
ajetrumpet Posted October 7, 2010 Author Share Posted October 7, 2010 thanks. appreciate your help. Quote Link to comment https://forums.phpfreaks.com/topic/215355-insert-into-trouble/#findComment-1119908 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.