fife Posted May 11, 2011 Share Posted May 11, 2011 ok this is killing me!!!!! I have a form with serveral fields but I'm only going to show one field for now <?php include('/Connections/dbconnect.php'); ?> <?php if(isset($_POST['long'])){ $name = trim($_POST['fullname']); $insertq = ("INSERT INTO customer_details (`full_name`,) VALUES (`$name`) "); $insert = mysql_query($insertq) or die (mysql_error); $url = "/index.php"; header("Location: $url"); } ?> <form action="" method="POST" name="longform1" id="longform1" > <input name="fullname" type="text" id="fullname" size="25" maxlength="50" /> <input type="submit" name="long" id="long" value=" Submit " /> </form> in the data base I have a table called "customer_details" which has customerID, full_name simple stuff so far!!!!!!!!!!! the database conntect file has............... $hostname_superconnect = "localhost"; $database_superconnect = "connect"; $username_superconnect = "name"; $password_superconnect = "password"; $superconnect = mysql_pconnect($hostname_superconnect, $username_superconnect, $password_superconnect) or trigger_error(mysql_error(), mysql_select_db($database_superconnect); when I enter a name into the field the page comes back blank and says only.... mysql_error When I check the server error logs i get..... [Wed May 11 16:17:25 2011] [error] [client ] File does not exist: /home/sites/site.com/public_html/none [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: include(../Connections/dbconnect.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/sites/site.com/public_html/index.php on line 1, referer: http://www.site.com/index.php [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: include(../Connections/dbconnect.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/sites/site.com/public_html/index.php on line 1, referer: http://www.site.com/index.php [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening '../Connections/dbconnect.php' for inclusion (include_path='.:/usr/share/pear5') in /home/sites/site.com/public_html/index.php on line 1, referer: http://www.site.com/index.php [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: Access denied for user 'sit'@'localhost' (using password: NO) in /home/sites/site.com/public_html/index.php on line 14, referer: http://www.site.com/index.php [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: A link to the server could not be established in /home/sites/site.com/public_html/index.php on line 14, referer: http://www.site.com/index.php Does anybody know whats wrong here. It must be a server error but thats just a beginners guess Quote Link to comment https://forums.phpfreaks.com/topic/236110-server-error/ Share on other sites More sharing options...
fugix Posted May 11, 2011 Share Posted May 11, 2011 okay i noticed two errors in your code..both having to deal with the mysql_error() function. 1. this line $insert = mysql_query($insertq) or die (mysql_error); should be $insert = mysql_query($insertq) or die (mysql_error()); you forgot the parenthesis around your mysql_error() function...which it why it was only printing the string "mysql_error" 2. in your connection page you are missing a parenthesis for the mysql_error() function inside of your trigger_error() function.. $superconnect = mysql_pconnect($hostname_superconnect, $username_superconnect, $password_superconnect) or trigger_error(mysql_error(), should be $superconnect = mysql_pconnect($hostname_superconnect, $username_superconnect, $password_superconnect) or trigger_error(mysql_error()), we will start there...once you change the above, show me what you get Quote Link to comment https://forums.phpfreaks.com/topic/236110-server-error/#findComment-1213857 Share on other sites More sharing options...
fife Posted May 11, 2011 Author Share Posted May 11, 2011 ok 1 min Quote Link to comment https://forums.phpfreaks.com/topic/236110-server-error/#findComment-1213859 Share on other sites More sharing options...
fife Posted May 11, 2011 Author Share Posted May 11, 2011 ok new code. the form........... <?php include('Connections/superconnect.php'); ?> <?php if(isset($_POST['long'])){ $name = trim($_POST['full-name']); $insertq = "INSERT INTO `customer_details` (`full_name`) VALUES (`$name`)"; $insert = mysql_query($insertq) or die (mysql_error()); $url = "/index.php"; header("Location: $url"); } ?> <form action="" method="POST" name="longform1" id="longform1" > <input name="fullname" type="text" id="fullname" size="25" maxlength="50" /> <input type="submit" name="long" id="long" value=" Submit " /> </form> the database..... table = customer_details full_name the new error............. Unknown column 'danny' in 'field list' It cant be an unknown column as thats now all there is. No more server error though so thank you for that. Quote Link to comment https://forums.phpfreaks.com/topic/236110-server-error/#findComment-1213863 Share on other sites More sharing options...
fugix Posted May 11, 2011 Share Posted May 11, 2011 I believe that it is because you are placing backticks around the variable that you want to insert, instead of this $insertq = "INSERT INTO `customer_details` (`full_name`) VALUES (`$name`)"; try this $insertq = "INSERT INTO `customer_details` (`full_name`) VALUES ($name)"; Quote Link to comment https://forums.phpfreaks.com/topic/236110-server-error/#findComment-1213867 Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2011 Share Posted May 11, 2011 String data must be enclosed in single-quotes. Quote Link to comment https://forums.phpfreaks.com/topic/236110-server-error/#findComment-1213868 Share on other sites More sharing options...
fugix Posted May 11, 2011 Share Posted May 11, 2011 he is right, so you would have $insertq = "INSERT INTO `customer_details` (`full_name`) VALUES ('$name')"; Quote Link to comment https://forums.phpfreaks.com/topic/236110-server-error/#findComment-1213869 Share on other sites More sharing options...
fife Posted May 11, 2011 Author Share Posted May 11, 2011 thankyou both! Quote Link to comment https://forums.phpfreaks.com/topic/236110-server-error/#findComment-1213871 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.