Jump to content

NorthWind

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

NorthWind's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello i have a problem with a code. the problem is very weird because this code actually works but sometimes it doesnt. I checked the code for hrs but could not find a problem with it. The code basicly does some database updates on the recent data. updates a few fields... The code actually says that it has updated but sometimes when you go check it from the database, it did not! I'm using MS SQL 2000 on a windows 2003 server, installed 4.4.0. I'm giving all these info because i started to think that its a database problem since the code sometimes work. Did anyone experienced this kind of problem, pls let me know. thanks [code] <?php         echo "<table align='center' border='0' cellpadding='6' cellspacing='3'>";         echo "<td height='406' valign='center' align='center'>";         require_once("config.php");         $itemCode = $_GET['itemCode'];         $custID = $_GET['custID'];         $jobID = $_GET['jobID'];         $serial = $_GET['serial'];         $eqid = $_GET['eqid'];         //$myobno = $_GET["myob"];         $custname = $_GET["custname"];         $custref = $_GET["custref"];         //$pdate = $_GET["purchaseDate"];                  echo $itemCode; echo "<br>";         echo $jobID;echo "<br>";         echo $serial;echo "<br>";         echo $eqid;echo "<br>";         echo $custname;echo "<br>";         //$jobInvoiceStatus = $_GET['jobInvoiceStatus'];         // Query database         $query = "Update JobEquipment SET jobID='$jobID', jobInvoiceStatus='Not Yet Invoiced', custname='$custname', custreference='$custref', sold='1' where (itemCode = '$itemCode') and (serial = '$serial') and (equipID = '$eqid')";         $result = mssql_query($query, $link);         //$row = @mssql_fetch_array($result);                      //if there were no errors ($result  == true or has a value)         if ($result)             {             echo "<h3>Success ! \n";             echo "<p>Item( $itemCode ) with serial: $serial has been added to the job.";             echo "<p><a href='serials.php'>To Equipment/Serials Page</a> \n";             echo "<p><a href='job.php?jobID=$jobID'>Back to Job</a> \n";                      //start of decrease quantity         if ($jobID!="")         {         $querysee = "SELECT * FROM Inventory where (itemCode = '$itemCode')";             $resultsee = mssql_query($querysee, $link);             //$rowsee = @mssql_fetch_array($resultsee);             //$quantity=$rowsee["quantity"];                                       while ($rowsee = @mssql_fetch_array($resultsee))                     {                         $quantity=$rowsee["quantity"];                     //    if ($itemCode==$row["itemCode"])                     //    {                                 $quantity--;                             $queryminus = "UPDATE Inventory SET quantity='$quantity' where itemCode='$itemCode'";                             $resultminus = mssql_query($queryminus, $link);                                          }         }                         // end of decrease quantity                                                }         else             {             echo "<h2>Database encountered errors with what was input<br>";             }         echo "</td>";         echo "</table>"; ?> [/code]
  2. [code] <?php                                            echo "<table align='center' border='0' cellpadding='6' cellspacing='3'>";         echo "<td height='406' valign='center' align='center'>";         require_once("config.php");         $cname = $_POST['cname'];         $sno = $_POST['sno'];         $tref = $_POST['tref'];         $accno = $_POST['accno'];         $service = $_POST['service'];         $speed = $_POST['speed'];         $data = $_POST['data'];         $rdate = $_POST['realDate'];         $owed = $_POST['owed'];         $paid = $_POST['paid'];                               $querycnt = "SELECT * from telstra";         $resultcnt = mssql_query($querycnt, $link);         $num_itemscnt = mssql_num_rows($resultcnt);                  if ($num_itemscnt <= 0)             { $num_itemscnt=1;}         else             {$num_itemscnt++;}                  //$rdate2='20/05/2006';                  $query = "INSERT INTO telstra (id, custname, servno, telstraref, accno, service, speed, data, datesubmit, cown, cpaid) VALUES ('$num_itemscnt', '$cname', '$sno', '$tref', '$accno', '$service', '$speed', '$data', '$rdate', '$owed', '$paid')";         $result = mssql_query($query, $link);         if ($result)             {             echo $rdate;             echo "<h3>Success ! \n";             echo "<p>$cname has been added to the database.";             echo "<p><a href='telstra_list.php'>List All Customers' Subscriptions </a> \n";             }         else             {             echo "<h2>error with database! - Customer May Already Exist";             }         echo "</td>";         echo "</table>";          ?> [/code] i got some stuff from the previous page with post, then enter em to the db. the problem is the datefield does not get written to the db. I echo it too to check i get it or not, it gets it ok and shows 19/05/2006 but when i check the db, i c <NULL>. the db field for date is datetime with 8 lenght and allow nulls. any ideas guys? thanks
  3. thank u Samuel it worked like magic ;) [!--quoteo(post=374580:date=May 17 2006, 02:56 PM:name=samshel)--][div class=\'quotetop\']QUOTE(samshel @ May 17 2006, 02:56 PM) [snapback]374580[/snapback][/div][div class=\'quotemain\'][!--quotec--] try value="$num" instead of value=$num in textbox tag similarly for all textboxes... hth [/quote]
  4. [code] $num=0;                 while ($row = @mssql_fetch_array($result3))                     {                     $num++;                                                                                 $itemCode=$row["itemCode"];                                                                                 $description_query = "SELECT * FROM Inventory where itemCode = '$itemCode'";                     $description_result = mssql_query($description_query, $link);                     $description_row = @mssql_fetch_array($description_result);                     $description=$description_row["description"]; $serial=$row["serial"]; echo "<tr align='left'>"; echo"            <td><input name='no[]' type='text' id='no1' size='3' value=$num></td>";                     echo"            <td><input name='description[]' type='text' id='description' size='70' value=$description></td>";                     echo"            <td><input name='serial[]' type='text' id='serial' value=$serial></td>"; [/code] ok this is my code. the problem is, im pulling stuff off the db and listing them 1 by 1 in text boxes. so i used txtbox arrays. the problem is when i try to pull and list data which has two or more words in it (like field name has John Doe), the code just shows John. The array doesnt get the whole thing. Is there a way to make the array show all? Thanks
  5. solved this by coding php to do it for me!
  6. thanks i did it already but this is shorter as well, ill use this next time i have to use it. thanks :) [!--quoteo(post=374226:date=May 16 2006, 04:55 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 16 2006, 04:55 PM) [snapback]374226[/snapback][/div][div class=\'quotemain\'][!--quotec--] There is a function called money_format() that should be able to do what you want, although in the PHP manual it says that it is available in PHP versions >= 4.3.0. I'm running 4.3.11 on my development machine and it does not recognise the function, some others are having the same issue by reading the comments section on the manual page. If you can get it to work, great, if not, heres a shorter way of doing it than you currently have... [code]<?php function ten($number) {     $length = strlen($number);     if($length < 10) {         for($i=0; $i<(10-$length); $i++) {             $number = "0".$number;         }     }     return $number; } echo ten(54782); //Prints 0000054782 ?>[/code] [/quote]
  7. here is my code: [code] $zero=0; switch ($serial)                 {                 case 'na':                   $querycms = "SELECT * FROM cmserial";                   $resultcms= mssql_query($querycms, $link);                   $num_itemscm = mssql_num_rows($resultcms);                                                   //$serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm);}                    echo strlen($num_itemscm);                   echo $num_itemscm;                  switch (strlen($num_itemscm))                     {                         case '1':                             if ($num_itemscm==9)                                 { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);}                             else                                 { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);}                         break;                             case '2':                             if ($num_itemscm==99)                                 { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);}                             else                                 { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);}                         break;                         }                                   break;                                    case '':                   $serial = '(not entered)';                   break;                 } [/code] i'm trying to make the numbers look like 0000000001 rather than just 1, for serial purposes. so the serials look like this CM-0000000001. total 10 digits. now as you know when it incrases from 9 to 10, i need to decrease a zero from the code so i used case for all lengths. my problem is for example when we have 9 numbers in the db, it counts them and sees tat it will increase to 10 for the next lvl but instead of decreasing zeros by 1 and increasing 9 by 1 to 10 and concatting all; it simply does not run the code where "if ($num_itemscm==9) { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);}" and directypasses to the else section and does that. any ideas appriciated? thanks
  8. Hello I'm coding a serial system for the firm I'm working for. We want to implement our own serial number to some items and we want to name the products like: CM-000001, CM-000002 and so on. I'd like to know how we can keep a number in 000001 format in the database? It's MS SQL Server. I tried to change the precision and etc after making the field as decimal but didnt work. Any help will be appriciated? Thanks
  9. [!--quoteo(post=374176:date=May 16 2006, 09:45 AM:name=Crimpage)--][div class=\'quotetop\']QUOTE(Crimpage @ May 16 2006, 09:45 AM) [snapback]374176[/snapback][/div][div class=\'quotemain\'][!--quotec--] You have...: if ($num_itemscm=<0) the number of rows returned are never going to be less than 0, so just use if ($num_itemscm=0) or if ($num_itemscm<1) David. [/quote] Thanks you David, works like magic. I'm from australia as well :)
  10. Hello guys I have a problem and can't seem to find whats wrong with it. The code is here [code] switch ($serial)                 {                 case 'na':                   $querycms = "SELECT * FROM cmserial";                   $resultcms= mssql_query($querycms, $link);                   $num_itemscm = mssql_num_rows($resultcms);                                echo $num_itemscm;                      if ($num_itemscm=<0)                   { $serial=0;}                   else                   { $serial=$num_itemscm++;}                   break;                                      case '':                   $serial = '(not entered)';                   break;                 } [/code] it returns me an empty blank white page. I closed some parts and at last found out that the problem is in the if section of it. Any help will be appriciated since I can not find what's wrong with this code since last friday. When you close the IF and else section it works, when i put it in, it doesnt. thanks
×
×
  • 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.