thefreebielife Posted May 22, 2007 Share Posted May 22, 2007 using this script i am getting a column count error but im not sure where and why. everything seems okay.. <? $username = $_SESSION['username']; $data = mysql_query("SELECT * FROM users WHERE username='$username'") or die(mysql_error()); $info = mysql_fetch_array($data); $giftid = $info['gid']; $ostatus = $info['ostatus']; $dead = $info['dead']; $date = date("F j, Y"); $uid = $info['uId']; $fname = $info['fname']; $address = $info['address']; $city = $info['city']; $state = $info['state']; $zip = $info['zip']; $status = "Pending"; $result2 = mysql_query("select * from users WHERE rid=$uid && ostatus >=1"); $count2=mysql_num_rows($result2); //show gift $data2 = mysql_query("SELECT * FROM gifts WHERE gId='$giftid'") or die(mysql_error()); $r = mysql_fetch_array($data2); $gref=$r["gRef"]; $gname=$r["gName"]; $data3 = mysql_query("SELECT * FROM orders WHERE ousername='$username'"); $count3=mysql_num_rows($data3); if ($date != $dead && $count2 >= $gref && $ostatus >= 1 && $dead != 1 or $count3 == 1) { $data3 = mysql_query("SELECT * FROM orders WHERE ousername='$username'"); $count3=mysql_num_rows($data3); if ($count3 == 0) { $insert = mysql_query("insert into orders values ('', '$username', '$fname', '$address', '$city', '$state', '$zip', '$date', '$status', '$gname', 'not on hold')") or die("Could not insert data because ".mysql_error()); } $data3 = mysql_query("SELECT * FROM orders WHERE ousername='$username'"); $info2 = mysql_fetch_array($data3); $odate = $info2['date']; $ostatus = $info2['ostatus']; $ogiftname = $info2['ogiftname']; $ostate = $info2['ostate']; $oholdreason = $info2['oholdreason']; ?> <div align="center"> <p>Your Order </p> <p> </p> <p> </p> <p> </p> </div> <table width="733" style="border: 1px dashed red; padding: 4px 4px 4px 4px; margin-left:30px"> <tr> <td style="border-bottom: 1px solid red "> <div align="center"><strong>Address</strong></div></td> <td style="border-bottom: 1px solid red "> <div align="center"><strong>City</strong></div></td> <td style="border-bottom: 1px solid red "> <div align="center"><strong>State</strong></div></td> <td style="border-bottom: 1px solid red "> <div align="center"><strong>Zip</strong></div></td> <td style="border-bottom: 1px solid red "> <div align="center"><strong>Status</strong></div></td> <td style="border-bottom: 1px solid red "> <div align="center"><strong>Date</strong></div></td> <td style="border-bottom: 1px solid red "> <div align="center"><strong>Gift Name </strong></div></td> </tr> <tr> <td> <div align="center"><strong><? echo "$address"; ?></strong></div></td> <td> <div align="center"><strong><? echo "$city"; ?></strong></div></td> <td> <div align="center"><strong><? echo "$ostate"; ?></strong></div></td> <td> <div align="center"><strong><? echo "$zip"; ?></strong></div></td> <td> <? if ($ostatus == "Pending") { ?> <div align="center"><font color="#FF9900"><strong><? echo "$ostatus"; ?></strong></font></div> <? } ?> <? if ($ostatus =="Processing") { ?> <div align="center"><font color="#0066FF"><strong><? echo "$ostatus"; ?></strong></font></div> <? } ?> <? if ($ostatus =="Approved") { ?> <div align="center"><font color="#660099"><strong><? echo "$ostatus"; ?></strong></font></div> <? } ?> <? if ($ostatus == "Shipped") { ?> <div align="center"><font color="#00FF00"><strong><? echo "$ostatus"; ?></strong></font></div> <? } ?> <? if ($ostatus == "On Hold") { ?> <div align="center"><font color="red"><strong><? echo "$ostatus"; ?></strong></font></div> <? } ?> </td> <td> <div align="center"><strong><? echo "$odate"; ?></strong></div></td> <td> <div align="center"><strong><? echo "$ogiftname"; ?></strong></div></td> </tr> <? if ($ostatus == "On Hold") { ?> <tr> <Td colspan="10" align="center"> <strong><font color="#FF0000">Hold Reason: <? echo "$oholdreason"; ?></font></strong> </Td> </tr> <? } ?> </table> <? } else { echo "<div align=center>You Do Not Have The Requirements To Place an Order</div>"; echo '<meta http-equiv="refresh" content="1;url=main.php">'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/52571-column-count-error/ Share on other sites More sharing options...
Barand Posted May 22, 2007 Share Posted May 22, 2007 You insert 11 values into table orders. How many columns are there in the table definition? BTW, if the first is an auto_increment column, the value should be NULL, not an empty string. Quote Link to comment https://forums.phpfreaks.com/topic/52571-column-count-error/#findComment-259458 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.