Jump to content

server error


fife

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.