Jump to content

help with database connections


scriptjet

Recommended Posts

Wasn't really sure what to call this topic, and I'm also not sure how to ask this question.  Here is what I have, and the problem I'm having.

 

I have an html form on a webpage that sends information into 2 different tables in a database I have.  One table is not important to the topic, the other table is where i'm having my problem. 

 

The user submits their information from the form and the info goes into the tables.  There is another page that displays the names of the users on a "wall" that populates from the second table in the database.  The second table takes information from the form they filled out and displays their name on the wall based on that (most importantly whether or not they can be e-mailed from the wall or not).

 

The issue I am having (and this is probably the long way of asking this) is that when some people fill out the form their info does not go into either database.  I know the functionality works, because their have been a couple of users that have signed up and everything worked fine for them.

 

I'm thinking this may be a connection issue possibly due to a firewall or something.  Any ideas on this?  The website is

 

http://itgetsbetter.tsagl.org

 

the form to fill out is under the button "Take the Pledge" and the names are displayed under "View the Wall".  If someone wouldn't mind to try out the functionality of the form for me (I need people that have some technical experience to do this because most of the people that I work with have no idea what I am talking about when trying to troubleshoot this with them).  I assure you that if everything works, I will remove your information from my database.  This site is only out to a few people at the moment, but I am planning on taking it public in the next couple of days. 

 

I would display code here, but I'm not sure what code you would need to see in order to help with this.  I just think this is a connection issue; I just need to know how to test it or how to rectify the issue. 

 

Thanks for your help (and please don't hate too much on the design on the site; i'm more of a programmer than a designer).

 

 

Link to comment
Share on other sites

here is the handling script for the form.  the pledgewall table is the table that dispalys to names on the "wall".

 

<?php

require ("../../connectigb.php");

$fName = $_POST ['fname'];
$lName = $_POST ['lname'];
$email = $_POST ['email'];
$zipCode = $_POST ['zipcode'];
$phone = $_POST ['phone'];
$receive = $_POST ['receive'];
$link = $_POST ['link'];

if ($link == "yes" && ($fName != "" || $lName != "")) {
$pledgename = "<a href=\"mailto:$email\">$fName $lName</a>";
} else {
$pledgename = "$fName $lName";
}

if ($pledgename != "") {
$sql2 = mysql_query ("INSERT INTO pledgewall (pledgeName) VALUES ('$pledgename')");
}

$sql = mysql_query ("INSERT INTO pledges (fName, lName, eMail, zipCode, phone, receive, link) VALUES ('$fName', '$lName', '$email', '$zipCode', '$phone', '$receive', '$link')");

?>

 

Link to comment
Share on other sites

this is the code that is displaying the information from the "pledgewall" table -- although not sure if this will help being as how the problem is that the information is not always getting passed to the table.

 

<table border='0' align='center' style='width:960px;'><tr>

<?php 

require ("connectigb.php");


$result = mysql_query ("SELECT pledgeName FROM pledgewall");

if($result && mysql_num_rows($result) > 0)
{
    $i = 0;
    $max_columns = 5;
    while($row = mysql_fetch_array($result))        
   {
       // make the variables easy to deal with
       extract($row);

       // open row if counter is zero
       if($i == 0)
          echo "<tr>";

       // make sure we have a valid product
       if($pledgeName != "" && $pledgeName != null)
          echo "<td class='pledgelabel'>$pledgeName</td>";
    
       // increment counter - if counter = max columns, reset counter and close row
       if(++$i == $max_columns) 
       {
           echo "</tr>";
           $i=0;
       }  // end if 
   } // end while
} // end if results

// clean up table - makes your code valid!
if($i < $max_columns)
{
    for($j=$i; $j<$max_columns;$j++)
        echo "<td> </td>";
}
?>
</tr></table>

Link to comment
Share on other sites

Databases can be configured not to allow certain values and types as well as to require certain values to be of specific sizes, uniqueness, ... well, almost any sort of requirement you can think of a database table can have on its values.  I think if there's an issue where sometimes people can submit data and it gets stored and other times it does not then we're looking at a problem with the data.  It would be very beneficial to turn on error reporting by putting this at the top of your handling script for some testing to see if you get a message back from MySQL about possible errors with the query when different values are passed through it.  This will also let you know if you're having undefined value assignments etc. so only use this for testing. 

 

error_reporting(E_ALL);
ini_set("display_errors', 1); 

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.