Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    mwm
    mwm is offline
    Regular Coder
    Join Date
    Oct 2005
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    occasionaly a 0 is entered in table not ID

    Can some tell me why every so often a 0 is entered in one of my tables instead of the user ID. This happens maybe every 15 - 20 entries.

    Thanks

  • #2
    New Coder
    Join Date
    Feb 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well you will deserve this answer.

    maybe is a random id ?

  • #3
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Where are you getting the user ID? Is there some reason why it isn't set? Would need to see some code to help much.

  • #4
    mwm
    mwm is offline
    Regular Coder
    Join Date
    Oct 2005
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the code the problem is where the id is inserted into the followup table on the second page. thanks for looking. Hey I'm a beg cubbie fun too. From the burbs.

    ### first ####

    <html>
    <body>
    <head><link rel=stylesheet type=text/css href=css/default.css>
    <script language="javascript" src="http://69.212.88.203/guestreg/cal2.js"></script>
    </head>
    <form name = "addtouch" action = "followupdate.php" method ="POST"></head>
    <h1><p align=center>The Corporation</p></h1>
    <h3><p align=center>Guest History </p></h3>
    <h3><p align=center></center></p></h3>
    <p align =center>

    <a href="guestmain.php">&nbsp;&nbsp;Main </a>
    <?echo $row[11]?><a href="pethree.php">&nbsp;&nbsp; P/E<a href="contacteditfour.php">&nbsp;&nbsp; Status Change </a></center>


    <br>
    <hr>

    <?

    include "conn.php";
    session_start();
    session_register("id");

    $tpoint = $_POST['tpoint'];
    $tpointdate = $_POST['tpointdate'];
    $note = $_POST['note'];
    $notedate = $_POST['notedate'];
    $lname = $_POST['lname'];





    $mysql = "SELECT * from cust where id = '$id' ";






    $result= mysql_query($mysql) or die ("Can't connect");
    $row = mysql_fetch_row($result);

    $id = $row[0];

    $mysql1 = "SELECT fname, lname,address,city,state,zip,hphone,cphone,wphone, email from cust where id = '$id'";







    $result1= mysql_query($mysql1) or die ("Can't connect");




    ?>
    <?

    echo "<table border=\"0\">";
    echo "<th>Guest</th>";
    echo "<th></th>";
    echo "<th>Address</th>";
    echo "<th>City</th>";
    echo "<th>State</th>";
    echo "<th>Zip</th>";
    echo "<th>Phone</th>";
    echo "<th>Cell</th>";
    echo "<th>Work</th>";
    echo "<th>Email</th>";


    $j = true;
    while ($row = mysql_fetch_row($result1))


    {
    if($j)
    $j= false;

    else
    $j=true;
    echo "<tr>";
    for ($i=0;$i<mysql_num_fields($result1);$i++) {
    if ($j) {

    echo "<td bgcolor=\"#CCFF99\">";

    }
    if (!$j) {

    echo "<td bgcolor=\"#FFFFCC\">";
    }
    echo $row[$i];
    echo "</td>";

    }

    }
    echo "</table>";






    ?>

    <?

    $mysql2 = "SELECT status, level, adulthousehold,childhousehold,nameage from cust where id = '$id'";


    $result2= mysql_query($mysql2) or die ("Can't connect");



    ?>
    <?

    echo "<table border=\"0\">";
    echo "<th>Status</th>";
    echo "<th>Level</th>";
    echo "<th>Adults</th>";
    echo "<th>Children</th>";
    echo "<th>Names</th>";




    $j = true;
    while ($row = mysql_fetch_row($result2))

    {
    if($j)
    $j= false;

    else
    $j=true;
    echo "<tr>";
    for ($i=0;$i<mysql_num_fields($result2);$i++) {
    if ($j) {

    echo "<td bgcolor=\"#CCFF99\">";

    }
    if (!$j) {

    echo "<td bgcolor=\"#FFFFCC\">";
    }
    echo $row[$i];
    echo "</td>";

    }

    }
    echo "</table>";

    ?>
    <?



    $mysql3 = "SELECT realname,realcomp,realadd,realphone from realtor where id = '$id'";




    $result3= mysql_query($mysql3) or die ("Can't connect");
    echo "<th>&nbsp;Realtor</th>";
    echo "<table border=\"0\">";
    $j = true;
    while ($row = mysql_fetch_row($result3))

    {
    if($j)
    $j= false;

    else
    $j=true;
    echo "<tr>";
    for ($i=0;$i<mysql_num_fields($result3);$i++) {
    if ($j) {

    echo "<td bgcolor=\"#CCFF99\">";

    }
    if (!$j) {

    echo "<td bgcolor=\"#FFFFCC\">";
    }
    echo $row[$i];
    echo "</td>";

    }

    }
    echo "</table>";

    ?>


    <br>
    <br>
    <hr>
    <p align = "center">
    Touch Point <select name ="tpoint"><option value = ""><option value = "Postcard ">Post Card<option value="Email Lead">Email Lead<option value ="Call Lead">Call Lead<option value ="Personal Note">Personal Note<option value ="Letter">Letter<option value ="Flyer">Flyer<option value ="Child Note">Child Note<option value ="Walk In">Walk In<option value ="Guest Call">Guest Call In</select> Demo <select name ="demo"><option value = ""><option value = "Model Demo">Model Demo <option value = "Site Demo">Site Demo<option value = "Model Visit">Model Visit<option value = "PE">PE<option value = "B Back">B Back </select>
    <script language="javascript" src="http://69.212.88.203/guestreg/cal_conf2.js"></script>
    Appointment <input type="text" name="appdate" size="10"><a href="javascript:showCal('Calendar11')">Select Date</a>

    <br>

    <br>
    <p align = "center">&nbsp;&nbsp; Notes:</p></center><p align = "center"><textarea rows="8" cols= "80" name ="note"></textarea></center>
    <p><input type=Submit name=Submit style="font-size:15" value="Save"> <p>

    </body>
    </html>



    #### Second

    <?
    include "conn.php";
    session_start();
    header("Location:guestmain.php");
    echo $id;
    $lname = $_POST['lname'];
    echo $lname;


    ?>
    <html>

    <form enctype = "multipart/form-data" method= "POST" >
    <head><link rel=stylesheet type=text/css href=css/default.css></head>

    <?




    $tpoint = $_POST['tpoint'];
    echo $tpoint;
    echo $demo;
    echo $id;
    echo $appdate;

    if (!empty($note))

    ##################### HERE IS WHERE THE PROBLEM LIES #########################

    {
    $query = "insert into followup ( id,lname, note) values ('$id','$lname','$note')";

    $result = mysql_query($query) or die ("Could not insert");

    } else {
    echo "Bad";
    }


    if (!empty($tpoint))

    {
    $query = "insert into followup ( id, tpoint,tpdate,tpcount) values ('$id','$tpoint',now(),'1')";
    $result = mysql_query($query) or die ("Could not insert");

    } else {
    echo "Bad";
    }


    if (!empty($demo))
    {
    $query2 = "insert into demotbl ( id,lname, demo,demodate) values ('$id','$lname','$demo',now())";

    $result2 = mysql_query($query2) or die ("Could not insert");


    } else {
    echo "Bad";
    }



    ?>

    <?


    if (!empty($appdate))
    {
    $query3 = "insert into apptbl ( id,lname, appdate) values ('$id','$lname','$appdate')";

    $result3 = mysql_query($query3) or die ("Could not insert");


    } else {
    echo "Bad";
    }

    echo $appdate;


    ?>




    </body>
    </form>
    </html>

  • #5
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Been a miserable year for the cubs again. Hopefully they can get their pitching rotation cleaned up a bit for next year.

    Off the top of my head, instead of using the session_register function try setting and use the session variable directly and see if you have any better results.

    PHP Code:
    $_SESSION['id'] = $row[0]; 
    Might also move the session_start() function to the very top of all of your pages. Seems like there was an issue with that, or maybe it's just with cookie based sessions. That also wouldn't explain why it works some of the time either.

  • #6
    mwm
    mwm is offline
    Regular Coder
    Join Date
    Oct 2005
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes. I think you mean another YEAR for the Cubs.
    Well let me try your suggestions and see what happens as data is entered.

    Thanks again
    Go Bears

  • #7
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Next year is always their year right?

    Go 49ers Have no idea why I follow them except that I grew up when Montana and Rice were there.

    Anyway, let me know what happens.

  • #8
    mwm
    mwm is offline
    Regular Coder
    Join Date
    Oct 2005
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I made the change to sessions but it still inserting a 0 for the id every once and a while. Any more ideas. This is frustrating!

    Thanks

  • #9
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Just add an if statement that says if the id is 0, bypass the insert.

    Sure it's a bandaid, but if you log all the information you have available when that happens, maybe you'll find a pattern that leads to the cause of the problem.

  • #10
    mwm
    mwm is offline
    Regular Coder
    Join Date
    Oct 2005
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok this is what I did just before the insert. This should do right?

    if ($id ==0)
    {
    echo "ERROR id is 0";
    } else {

    insert code

    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •