473,839 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

After transferring to MySQL, date fieldvalues now show null

20 New Member
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im sorting out a few glitches though.

Since i upgraded from ms access database to MySQL, i have added about 4 articles to test the new setup. I note some fields aren't being added in the new mySql database for the new 4 records. When i ran the MySQK query analyser and checked to see what was in the database fields.. the "fldCreated " shows NULL, when it should be showing a date. In the query analyser, the dates BEFORE the new mysql database show:

nm_tbl_news n;
2008-10-15 08:28:31


but in the few articles i added after the transfer it doesn't have a date, it says NULL, which means the code adding the date to the database must be wrong.


I'm including some code from the newsadd.asp page, which is the page that is actually adding the news to the database and also some code from the include files on this page , which may be relevant


inc_api.asp
[code]
Expand|Select|Wrap|Line Numbers
  1. FUNCTION RFC822(dDate,iOffset)
  2.     Dim d
  3.     d = DateAdd("h",-iOffset,dDate)
  4.     RFC822 = Left(WeekDayName(WeekDay(d)),3) & ", " & Right(String(2,"0") & Day(d),2) & " " & Left(MonthName(Month(d)),3) & " " & Year(d) & " " & Right(String(2,"0") & Hour(d),2) & ":" & Right(String(2,"0") & Minute(d),2) & ":" & Right(String(2,"0") & Second(d),2) & " " & "GMT"
  5. END FUNCTION    



config.asp
Expand|Select|Wrap|Line Numbers
  1. <% Dim MyConn, APPLICATION_URL, arrLEVEL, SAFE_EXTENSIONS_ONLY, KEEP_LOGS, DB_TO_USE, ALL_ARTICLES_PAGE_SIZE, SET_EMAIL_COMP, SHOW_AUTHOR
  2.    Dim SEARCH_METHOD, SEARCH_IN, SEARCH_MODE, SEARCH_FOR
  3.  
  4.    Session.LCID = 1033
  5.  
  6.  
  7.  
  8.         ' Set to 1 if you are using MS Access, set to 2 if you are using MS SQL database, 3 for MySQL
  9.         DB_TO_USE = 3
  10.  
  11.  
  12.     ' Assemble date value
  13.     FUNCTION ASEMBLE_DATE_FORMAT(sDAY, sMONTH, sYEAR)
  14.         Dim DATE_FORMAT, sDATE                   
  15.  
  16.         DATE_FORMAT = 1 ' US Locale
  17.  
  18.         SELECT CASE DATE_FORMAT
  19.             CASE 1
  20.                 sDATE = sMONTH & "/" & sDAY  & "/" & sYEAR
  21.             CASE ELSE
  22.                 sDATE = sMONTH & "/" & sDAY  & "/" & sYEAR
  23.         END SELECT            
  24.         ASEMBLE_DATE_FORMAT = sDATE
  25.     END FUNCTION
  26.  
  27.  
  28.  
  29.     <% '// NO NEED TO MODIFY ANYTHING BELOW 
  30. FUNCTION CNT_DATE(sDATE)
  31.   IF IsDate(sDATE) = True THEN
  32.  
  33.     SELECT CASE DATE_FORMAT
  34.         CASE 1        'YYYYMMDD
  35.             CNT_DATE = Year(sDATE) & Right(Cstr(Month(sDATE) + 100),2) & Right(Cstr(Day(sDATE) + 100),2)
  36.         CASE 2        'YYYY-MM-DD
  37.             CNT_DATE = Year(sDATE) & "-" & Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Day(sDATE) + 100),2)
  38.         CASE 101    'mm/dd/yy 
  39.             CNT_DATE = Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Day(sDATE) + 100),2) & "/" & Right(Cstr(Year(sDATE)),2)
  40.         CASE 102    'yy.mm.dd
  41.             CNT_DATE = Right(Cstr(Year(sDATE)),2) & "." & Right(Cstr(Month(sDATE) + 100),2) & "." & Right(Cstr(Day(sDATE) + 100),2)
  42.         CASE 103    'dd/mm/yy
  43.             CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "/" & Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Year(sDATE)),2)
  44.         CASE 104    'dd.mm.yy
  45.             CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "." & Right(Cstr(Month(sDATE) + 100),2) & "." & Right(Cstr(Year(sDATE)),2)
  46.         CASE 105    'dd-mm-yy
  47.             CNT_DATE = Right(Cstr(Day(sDATE) + 100),2) & "-" & Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Year(sDATE)),2)
  48.         CASE 110    'mm-dd-yy
  49.             CNT_DATE = Right(Cstr(Month(sDATE) + 100),2) & "-" & Right(Cstr(Day(sDATE) + 100),2) & "-" & Right(Cstr(Year(sDATE)),2)
  50.         CASE 111    'yy/mm/dd
  51.             CNT_DATE = Right(Cstr(Year(sDATE)),2) & "/" & Right(Cstr(Month(sDATE) + 100),2) & "/" & Right(Cstr(Day(sDATE) + 100),2)    
  52.         CASE 112    'yymmdd
  53.             CNT_DATE = Right(Cstr(Year(sDATE)),2) & Right(Cstr(Month(sDATE) + 100),2) & Right(Cstr(Day(sDATE) + 100),2)
  54.     END SELECT    
  55.   ELSE
  56.       CNT_DATE = Null
  57.   END IF
  58. END FUNCTION
  59. %>    

and this is the page that adds the news to the database, ive tried to only include relevant code, (or that which i think is relevant) as it is a long page, .

newsadd.asp
Expand|Select|Wrap|Line Numbers
  1. <!--#include file="inc_api.asp"-->
  2. <!--#include file="config.asp"-->
  3.  
  4.     <%Dim MODE, MESSAGE, CATE_STR, SQL, RS, CATE, AGENT, ACTIVE, ALLOW_C, ALLOW_V, TITLE, SUMMARY, IMAGE, CONTENT, I, _
  5.           arrCATE, ID, sDATE, eDATE, TID, TEMPLATE, A_C, A_V, APPROVE, HLITE, AGENT_STR, USE_VIEW
  6.  
  7.     MODE = Request.Form("mode")
  8.     TID  = Trim(Request.QueryString("TID"))
  9.  
  10.  
  11.     Call CREATE_SECURITY()    
  12.     IF NOT Trim(arrLEVEL(27)) = "1" THEN MESSAGE = "<li />Sorry, you don't have access to this section."    
  13.  
  14.     '
  15.     '<description> add new article to the DB </description>
  16.     '
  17.     IF MODE = "add" THEN
  18.  
  19.         With Request
  20.             arrCATE     = Split(APO(.Form("cate")),",")
  21.             AGENT    = APO(.Form("agent"))
  22.             ACTIVE   = CONVERT_NUM(.Form("active"))
  23.             ALLOW_C  = CONVERT_NUM(.Form("allow_c"))
  24.             ALLOW_V  = CONVERT_NUM(.Form("allow_v"))
  25.             TITLE    = APO(.Form("title"))
  26.             SUMMARY  = APO(STRIP_CODE(.Form("summary")))
  27.             USE_VIEW = APO(.Form("USE_VIEW"))
  28.             IMAGE    = APO(.Form("image"))            
  29.             CONTENT  = APO_LAX(.Form("content"))            
  30.             IF DB_TO_USE = 3 THEN
  31.                 sDATE = .Form("sY") & "-" & .Form("sM") & "-" & .Form("sD")    
  32.                 eDATE = .Form("eY") & "-" & .Form("eM") & "-" & .Form("eD")    
  33.             ELSE
  34.                 sDATE    = ASEMBLE_DATE_FORMAT(.Form("sD"),.Form("sM"),.Form("sY"))
  35.                 eDATE    = ASEMBLE_DATE_FORMAT(.Form("eD"),.Form("eM"),.Form("eY"))  
  36.             END IF  
  37.             HLITE    = CONVERT_NUM(.Form("hlite"))
  38.         End With
  39.  
  40.         Call CHECK_INP()        
  41.  
  42.         IF MESSAGE = "" THEN            
  43.             '
  44.             '<description> add article </description>
  45.             '               
  46.                      ELSE
  47.                 SQL = "INSERT INTO nm_tbl_news (fldTITLE, fldCONTENT, fldSUMMARY, fldACTIVE, fldAID, fldPOSTED, fldEXPIRES, fldIMAGE, fldALLOW_COMMENTS, fldALLOW_VOTING, fldHIGHLIGHT, fldUSE_VIEW) VALUES ('" & TITLE & "','" & CONTENT & "','" & SUMMARY & "'," & ACTIVE & "," & AGENT & ",'" & sDATE & "','" & eDATE & "','" & IMAGE & "'," & ALLOW_C & "," & ALLOW_V & "," & HLITE & ", " & USE_VIEW & ")"
  48.             END IF                
  49.             Call OPEN_DB()
  50.  
  51.             MyConn.Execute SQL
  52.  
  53.             SQL = "SELECT ID FROM nm_tbl_news WHERE fldTITLE='" & TITLE & "' AND fldAID = " & AGENT & " ORDER BY ID DESC"
  54.             Set RS = Server.CreateObject("ADODB.Recordset")
  55.             RS.Open SQL, MyConn    
  56.                  IF NOT RS.EOF THEN
  57.                      ID = trim(RS("ID"))
  58.                  END IF
  59.             RS.Close 
  60.  
  61.             '
  62.             '<description> add category association </description>
  63.             '              
  64.             FOR I = 0 to Ubound(arrCATE)
  65.                 IF IS_VALID_ID(Trim(arrCATE(I))) = True THEN
  66.                     SQL = "INSERT INTO nm_tbl_news_cate (fldNEWS_ID, fldCATE_ID) VALUES (" & ID & "," & Trim(arrCATE(I)) & ")"
  67.                     MyConn.Execute SQL
  68.                 END IF    
  69.             NEXT 
  70.  
  71.             ' { Append New Log Lin } 
  72.             Call APPEND_LOG(False, "Added new article ( " & TITLE & " ).", Session("ID"))            
  73.  
  74.             MyConn.close 
  75.             Set MyConn = Nothing                                    
  76.  
  77.             Response.Redirect "news.asp"
  78.             Response.End
  79.         END IF
  80.  
  81.     ELSE
  82.  
  83.         Call OPEN_DB()
  84.         '
  85.         '<description> Create the category drop down </description>
  86.         '        
  87.  
  88.         IF DB_TO_USE = 3 THEN
  89.             SQL = "SELECT ID, fldNAME, ID as ID1, 0 as ID2, 0 as ID3 FROM nm_tbl_cate WHERE fldLEVEL = 1 UNION SELECT nm_tbl_cate.ID, CONCAT(PARENT.fldNAME , ' > ' , nm_tbl_cate.fldNAME) AS NAME, PARENT.id, nm_tbl_cate.ID, 0 FROM nm_tbl_cate, nm_tbl_cate AS PARENT WHERE (nm_tbl_cate.fldLEVEL = 2) AND (nm_tbl_cate.fldPID =PARENT.ID) UNION SELECT nm_tbl_cate.ID, CONCAT(PARENT.fldNAME , ' > ' , SUBPARENT.fldNAME , ' > ' , nm_tbl_cate.fldNAME) AS NAME, PARENT.id, SUBPARENT.id, nm_tbl_cate.ID FROM nm_tbl_cate, nm_tbl_cate AS PARENT, nm_tbl_cate AS SUBPARENT  WHERE (nm_tbl_cate.fldLEVEL = 3) AND (nm_tbl_cate.fldPID =PARENT.ID) AND (nm_tbl_cate.fldSID =SUBPARENT.ID) ORDER BY `fldName` ASC"
  90.         ELSE        
  91.                     END IF            
  92.         Set RS = Server.CreateObject("ADODB.Recordset")
  93.         RS.LockType   = 1
  94.         RS.CursorType = 0
  95.  
  96.  
  97.         RS.Open SQL, MyConn    
  98.              WHILE NOT RS.EOF 
  99.                 CATE_STR = CATE_STR & "<option value='" & trim(RS("ID")) & "'>" & trim(RS("fldNAME")) & vbcrlf
  100.                 RS.MoveNext
  101.              WEND
  102.         RS.Close 
  103.         '
  104.  
  105.                 ELSE
  106.                     IF Session("ID") = trim(RS("ID")) THEN
  107.                         AGENT_STR = AGENT_STR & "<option selected='selected' style='background-color: #ffffea' value='" & trim(RS("ID")) & "'>" & trim(RS("fldNAME")) & vbcrlf
  108.                     END IF                
  109.                 END IF
  110.                 RS.MoveNext
  111.              WEND
  112.         RS.Close
  113.  
  114.         IF IS_VALID_ID(TID) THEN 
  115.  
  116.             SQL = "SELECT fldTEMPLATE FROM nm_tbl_template WHERE ID = " & TID
  117.             Set RS = Server.CreateObject("ADODB.Recordset")
  118.             RS.LockType   = 1
  119.             RS.CursorType = 0
  120.             RS.Open SQL, MyConn    
  121.                  IF NOT RS.EOF THEN
  122.                      TEMPLATE = trim(RS("fldTEMPLATE"))
  123.                  END IF
  124.             RS.Close     
  125.  
  126.         END IF           
  127.  
  128.         SQL = "SELECT fldA_V, fldA_C, fldAPPROVE FROM nm_tbl_settings WHERE ID = 1"
  129.         Set RS = Server.CreateObject("ADODB.Recordset")
  130.         RS.LockType   = 1
  131.         RS.CursorType = 0
  132.         RS.Open SQL, MyConn    
  133.              IF NOT RS.EOF THEN
  134.                 A_C     = Trim(RS("fldA_C"))
  135.                 A_V     = Trim(RS("fldA_V"))
  136.                 APPROVE = Trim(RS("fldAPPROVE"))
  137.              END IF
  138.         RS.Close 
  139.  
  140.         Set RS = Nothing        
  141.         MyConn.Close
  142.         Set MyConn = Nothing
  143.  
  144.     END IF    
  145.  
  146.  
  147.     %>
  148.  
  149.  
  150.  
  151.     <table width="100%" align="center" cellpadding="2" cellspacing="0" border="0">
  152.         <tr>
  153.  
  154.         </tr>
  155.     </table>
  156.     <br />
  157.     <table width="100%" align="center" cellpadding="2" cellspacing="0" border="1" bordercolor="whitesmoke" style="border-collapse: collapse;">
  158.         <tr bgcolor="whitesmoke">
  159.             <td class="MainTitle">Add New Article</td>
  160.             <td class="MainTitle" align="right">< <a href="templates.asp">Apply Template</a> ></td>
  161.         </tr>
  162.         <tr>
  163.             <td colspan="2">
  164.                 <br />       
  165.  
  166.                 <form action="newsadd.asp" method="post" name="frm">
  167.                 <table cellpadding="2" cellspacing="0" border="0" align="center" width="622">
  168.                     <tr>
  169.                         <td>Article&nbsp;By:</td>
  170.                         <td align="right"><select name="agent" class="textbox" style="width: 450px;"><%= AGENT_STR %></select></td>
  171.                     </tr>
  172.                     <tr>
  173.  
  174.                                                                <td>Publish Date:</td>
  175.                                         <td><select name="sM" id="sM"><%FOR I = 1 TO 12%><option<%If Trim(I) = Trim(Month(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td>
  176.                                         <td>/</td>
  177.                                         <td><select name="sD" id="sD"><%FOR I = 1 TO 31%><option<%If Trim(I) = Trim(day(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td>
  178.                                         <td>/</td>
  179.                                         <td><select name="sY" id="sY"><%FOR I = 2001 TO 2030%><option<%If Trim(I) = Trim(Year(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td>
  180.                                         <td></td>
  181.                                     </tr></table>        
  182.                                 </td>
  183.                                 <td>
  184.                                     <table align="right" cellpadding="2" cellspacing="0" border="0"><tr>
  185.                                         <td>Expires Date:</td>
  186.                                         <td><select name="eM" id="eM"><%FOR I = 1 TO 12%><option<%If Trim(I) = Trim(Month(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td>
  187.                                         <td>/</td>
  188.                                         <td id="eD"><select name="eD" id="eD"><%FOR I = 1 TO 31%><option<%If Trim(I) = Trim(Day(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td>
  189.                                         <td>/</td>
  190.                                         <td><select name="eY" id="eY"><%FOR I = 2001 TO 2030%><option<%If Trim(I) = Trim(Year(Date+365)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td>
  191.                                         <td></td>
  192.                                     </tr></table>        
  193.                                 </td>
  194.                             </tr></table>
  195.  
  196.                         </td>                    
  197.                     </tr>                    
  198.  
  199.                         </td>
  200.                     </tr><tr>
  201.                         <td colspan="2" align="right"><br /><input type="Submit" value="Add Article" onClick="return ValidateNewsArticle()" /><br /></td>
  202.                     </tr></table>                                
  203.                 <input type="Hidden" name="mode" value="add" />
  204.                 </form>
  205.                 <br /><br />
  206.             </td>
  207.         </tr>
  208.     </table>    
  209.  
  210. <!--#include file="inc_footer.asp"-->
I'd appreciate it if anyone could show me what to change and where. I'm not html literate, and realise the code above is probably not written in the best way, but im just concerned with getting it to function.

Much appreciated and thanks in advance
Nov 16 '08 #1
3 3550
Nicodemas
164 Recognized Expert New Member
On line 47 of your news_add.asp, there is no reference to a "fldCreated " in your SQL query. That means no value would be input to your table when this script fires off.

I have modified your file with important changes. See lines 18 - 23.

I created a new variable 'CREATE_DATE'.

The code on line 21 formats this date as "MM/DD/YYY"

Line 22 is just so I can get around modifying other files and thus complicating this for you.

Line 23 formats the date for MySQL insertion.

Skip to line 53 now. It now includes fldCreated.

Try this and let me know if it works.

Expand|Select|Wrap|Line Numbers
  1. <!--#include file="inc_api.asp"--> 
  2. <!--#include file="config.asp"--> 
  3.  
  4.     <%Dim MODE, MESSAGE, CATE_STR, SQL, RS, CATE, AGENT, ACTIVE, ALLOW_C, ALLOW_V, TITLE, SUMMARY, IMAGE, CONTENT, I, _ 
  5.           arrCATE, ID, sDATE, eDATE, TID, TEMPLATE, A_C, A_V, APPROVE, HLITE, AGENT_STR, USE_VIEW 
  6.  
  7.     MODE = Request.Form("mode") 
  8.     TID  = Trim(Request.QueryString("TID")) 
  9.  
  10.  
  11.     Call CREATE_SECURITY()     
  12.     IF NOT Trim(arrLEVEL(27)) = "1" THEN MESSAGE = "<li />Sorry, you don't have access to this section."     
  13.  
  14.     ' 
  15.     '<description> add new article to the DB </description> 
  16.     ' 
  17.     IF MODE = "add" THEN 
  18.         ''// added by nicodemas
  19.         twoDay      = day(date) :   if twoDay < 10 then twoDay = "0" & twoDay
  20.         twoMonth    = month(date) : if twoMonth < 10 then twoMonth = "0" & twoMonth
  21.         CREATE_DATE = ASEMBLE_DATE_FORMAT(twoDay,twoMonth,year(date)) 
  22.         DATE_FORMAT = 2
  23.         CREATE_DATE = CNT_DATE(CREATE_DATE)
  24.  
  25.         With Request 
  26.             arrCATE     = Split(APO(.Form("cate")),",") 
  27.             AGENT    = APO(.Form("agent")) 
  28.             ACTIVE   = CONVERT_NUM(.Form("active")) 
  29.             ALLOW_C  = CONVERT_NUM(.Form("allow_c")) 
  30.             ALLOW_V  = CONVERT_NUM(.Form("allow_v")) 
  31.             TITLE    = APO(.Form("title")) 
  32.             SUMMARY  = APO(STRIP_CODE(.Form("summary"))) 
  33.             USE_VIEW = APO(.Form("USE_VIEW")) 
  34.             IMAGE    = APO(.Form("image"))             
  35.             CONTENT  = APO_LAX(.Form("content"))             
  36.             IF DB_TO_USE = 3 THEN 
  37.                 sDATE = .Form("sY") & "-" & .Form("sM") & "-" & .Form("sD")     
  38.                 eDATE = .Form("eY") & "-" & .Form("eM") & "-" & .Form("eD")     
  39.             ELSE 
  40.                 sDATE    = ASEMBLE_DATE_FORMAT(.Form("sD"),.Form("sM"),.Form("sY")) 
  41.                 eDATE    = ASEMBLE_DATE_FORMAT(.Form("eD"),.Form("eM"),.Form("eY"))   
  42.             END IF   
  43.             HLITE    = CONVERT_NUM(.Form("hlite")) 
  44.         End With 
  45.  
  46.         Call CHECK_INP()         
  47.  
  48.         IF MESSAGE = "" THEN             
  49.             ' 
  50.             '<description> add article </description> 
  51.             '                
  52.                      ELSE 
  53.                 SQL = "INSERT INTO nm_tbl_news (fldCreated, fldTITLE, fldCONTENT, fldSUMMARY, fldACTIVE, fldAID, fldPOSTED, fldEXPIRES, fldIMAGE, fldALLOW_COMMENTS, fldALLOW_VOTING, fldHIGHLIGHT, fldUSE_VIEW) VALUES ('"& CREATE_DATE &"', '" & TITLE & "','" & CONTENT & "','" & SUMMARY & "'," & ACTIVE & "," & AGENT & ",'" & sDATE & "','" & eDATE & "','" & IMAGE & "'," & ALLOW_C & "," & ALLOW_V & "," & HLITE & ", " & USE_VIEW & ")" 
  54.             END IF                 
  55.             Call OPEN_DB() 
  56.  
  57.             MyConn.Execute SQL 
  58.  
  59.             SQL = "SELECT ID FROM nm_tbl_news WHERE fldTITLE='" & TITLE & "' AND fldAID = " & AGENT & " ORDER BY ID DESC" 
  60.             Set RS = Server.CreateObject("ADODB.Recordset") 
  61.             RS.Open SQL, MyConn     
  62.                  IF NOT RS.EOF THEN 
  63.                      ID = trim(RS("ID")) 
  64.                  END IF 
  65.             RS.Close  
  66.  
  67.             ' 
  68.             '<description> add category association </description> 
  69.             '               
  70.             FOR I = 0 to Ubound(arrCATE) 
  71.                 IF IS_VALID_ID(Trim(arrCATE(I))) = True THEN 
  72.                     SQL = "INSERT INTO nm_tbl_news_cate (fldNEWS_ID, fldCATE_ID) VALUES (" & ID & "," & Trim(arrCATE(I)) & ")" 
  73.                     MyConn.Execute SQL 
  74.                 END IF     
  75.             NEXT  
  76.  
  77.             ' { Append New Log Lin }  
  78.             Call APPEND_LOG(False, "Added new article ( " & TITLE & " ).", Session("ID"))             
  79.  
  80.             MyConn.close  
  81.             Set MyConn = Nothing                                     
  82.  
  83.             Response.Redirect "news.asp" 
  84.             Response.End 
  85.         END IF 
  86.  
  87.     ELSE 
  88.  
  89.         Call OPEN_DB() 
  90.         ' 
  91.         '<description> Create the category drop down </description> 
  92.         '         
  93.  
  94.         IF DB_TO_USE = 3 THEN 
  95.             SQL = "SELECT ID, fldNAME, ID as ID1, 0 as ID2, 0 as ID3 FROM nm_tbl_cate WHERE fldLEVEL = 1 UNION SELECT nm_tbl_cate.ID, CONCAT(PARENT.fldNAME , ' > ' , nm_tbl_cate.fldNAME) AS NAME, PARENT.id, nm_tbl_cate.ID, 0 FROM nm_tbl_cate, nm_tbl_cate AS PARENT WHERE (nm_tbl_cate.fldLEVEL = 2) AND (nm_tbl_cate.fldPID =PARENT.ID) UNION SELECT nm_tbl_cate.ID, CONCAT(PARENT.fldNAME , ' > ' , SUBPARENT.fldNAME , ' > ' , nm_tbl_cate.fldNAME) AS NAME, PARENT.id, SUBPARENT.id, nm_tbl_cate.ID FROM nm_tbl_cate, nm_tbl_cate AS PARENT, nm_tbl_cate AS SUBPARENT  WHERE (nm_tbl_cate.fldLEVEL = 3) AND (nm_tbl_cate.fldPID =PARENT.ID) AND (nm_tbl_cate.fldSID =SUBPARENT.ID) ORDER BY `fldName` ASC" 
  96.         ELSE         
  97.                     END IF             
  98.         Set RS = Server.CreateObject("ADODB.Recordset") 
  99.         RS.LockType   = 1 
  100.         RS.CursorType = 0 
  101.  
  102.  
  103.         RS.Open SQL, MyConn     
  104.              WHILE NOT RS.EOF  
  105.                 CATE_STR = CATE_STR & "<option value='" & trim(RS("ID")) & "'>" & trim(RS("fldNAME")) & vbcrlf 
  106.                 RS.MoveNext 
  107.              WEND 
  108.         RS.Close  
  109.         ' 
  110.  
  111.                 ELSE 
  112.                     IF Session("ID") = trim(RS("ID")) THEN 
  113.                         AGENT_STR = AGENT_STR & "<option selected='selected' style='background-color: #ffffea' value='" & trim(RS("ID")) & "'>" & trim(RS("fldNAME")) & vbcrlf 
  114.                     END IF                 
  115.                 END IF 
  116.                 RS.MoveNext 
  117.              WEND 
  118.         RS.Close 
  119.  
  120.         IF IS_VALID_ID(TID) THEN  
  121.  
  122.             SQL = "SELECT fldTEMPLATE FROM nm_tbl_template WHERE ID = " & TID 
  123.             Set RS = Server.CreateObject("ADODB.Recordset") 
  124.             RS.LockType   = 1 
  125.             RS.CursorType = 0 
  126.             RS.Open SQL, MyConn     
  127.                  IF NOT RS.EOF THEN 
  128.                      TEMPLATE = trim(RS("fldTEMPLATE")) 
  129.                  END IF 
  130.             RS.Close      
  131.  
  132.         END IF            
  133.  
  134.         SQL = "SELECT fldA_V, fldA_C, fldAPPROVE FROM nm_tbl_settings WHERE ID = 1" 
  135.         Set RS = Server.CreateObject("ADODB.Recordset") 
  136.         RS.LockType   = 1 
  137.         RS.CursorType = 0 
  138.         RS.Open SQL, MyConn     
  139.              IF NOT RS.EOF THEN 
  140.                 A_C     = Trim(RS("fldA_C")) 
  141.                 A_V     = Trim(RS("fldA_V")) 
  142.                 APPROVE = Trim(RS("fldAPPROVE")) 
  143.              END IF 
  144.         RS.Close  
  145.  
  146.         Set RS = Nothing         
  147.         MyConn.Close 
  148.         Set MyConn = Nothing 
  149.  
  150.     END IF     
  151.  
  152.  
  153.     %> 
  154.  
  155.  
  156.  
  157.     <table width="100%" align="center" cellpadding="2" cellspacing="0" border="0"> 
  158.         <tr> 
  159.  
  160.         </tr> 
  161.     </table> 
  162.     <br /> 
  163.     <table width="100%" align="center" cellpadding="2" cellspacing="0" border="1" bordercolor="whitesmoke" style="border-collapse: collapse;"> 
  164.         <tr bgcolor="whitesmoke"> 
  165.             <td class="MainTitle">Add New Article</td> 
  166.             <td class="MainTitle" align="right">< <a href="templates.asp">Apply Template</a> ></td> 
  167.         </tr> 
  168.         <tr> 
  169.             <td colspan="2"> 
  170.                 <br />        
  171.  
  172.                 <form action="newsadd.asp" method="post" name="frm"> 
  173.                 <table cellpadding="2" cellspacing="0" border="0" align="center" width="622"> 
  174.                     <tr> 
  175.                         <td>Article&nbsp;By:</td> 
  176.                         <td align="right"><select name="agent" class="textbox" style="width: 450px;"><%= AGENT_STR %></select></td> 
  177.                     </tr> 
  178.                     <tr> 
  179.  
  180.                                                                <td>Publish Date:</td> 
  181.                                         <td><select name="sM" id="sM"><%FOR I = 1 TO 12%><option<%If Trim(I) = Trim(Month(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td> 
  182.                                         <td>/</td> 
  183.                                         <td><select name="sD" id="sD"><%FOR I = 1 TO 31%><option<%If Trim(I) = Trim(day(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td> 
  184.                                         <td>/</td> 
  185.                                         <td><select name="sY" id="sY"><%FOR I = 2001 TO 2030%><option<%If Trim(I) = Trim(Year(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td> 
  186.                                         <td></td> 
  187.                                     </tr></table>         
  188.                                 </td> 
  189.                                 <td> 
  190.                                     <table align="right" cellpadding="2" cellspacing="0" border="0"><tr> 
  191.                                         <td>Expires Date:</td> 
  192.                                         <td><select name="eM" id="eM"><%FOR I = 1 TO 12%><option<%If Trim(I) = Trim(Month(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td> 
  193.                                         <td>/</td> 
  194.                                         <td id="eD"><select name="eD" id="eD"><%FOR I = 1 TO 31%><option<%If Trim(I) = Trim(Day(Date)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td> 
  195.                                         <td>/</td> 
  196.                                         <td><select name="eY" id="eY"><%FOR I = 2001 TO 2030%><option<%If Trim(I) = Trim(Year(Date+365)) Then %> selected<%End If%> value="<%=I%>"><%=I%><%NEXT%></select></td> 
  197.                                         <td></td> 
  198.                                     </tr></table>         
  199.                                 </td> 
  200.                             </tr></table> 
  201.  
  202.                         </td>                     
  203.                     </tr>                     
  204.  
  205.                         </td> 
  206.                     </tr><tr> 
  207.                         <td colspan="2" align="right"><br /><input type="Submit" value="Add Article" onClick="return ValidateNewsArticle()" /><br /></td> 
  208.                     </tr></table>                                 
  209.                 <input type="Hidden" name="mode" value="add" /> 
  210.                 </form> 
  211.                 <br /><br /> 
  212.             </td> 
  213.         </tr> 
  214.     </table>     
  215.  
  216. <!--#include file="inc_footer.asp"--> 
Nov 17 '08 #2
janetopps
20 New Member
Thanks so much, N

I tried the code and when i tried adding the article i got this error message. Remember before i could add the article , but there was no date in the fldCreated showing in the Mysql database


Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'twoDay'

/Admin/ne_add.asp, line 19


and the code on line 19 is

Expand|Select|Wrap|Line Numbers
  1. With Request
Anyhow i think it important to mention something, this script was set to run on different databases, 1 for Access, 2 for MS sql and 3 for MySQL

It was working fine on Access. But i didn't show you the part for the Access database
You said " fldCreated" was missing. But it was also missing from the code used for Access, and it worked fine then. Let me show you, the complete code for that part, as i only showed you the MySQL one,

Expand|Select|Wrap|Line Numbers
  1.  '<description> add article </description>
  2.             '               
  3.             IF DB_TO_USE = 1 THEN
  4.                 SQL = "INSERT INTO nm_tbl_news (fldTITLE, fldCONTENT, fldSUMMARY, fldACTIVE, fldAID, fldPOSTED, fldEXPIRES, fldIMAGE, fldALLOW_COMMENTS, fldALLOW_VOTING, fldHIGHLIGHT, fldUSE_VIEW) VALUES ('" & TITLE & "','" & CONTENT & "','" & SUMMARY & "'," & ACTIVE & "," & AGENT & ",#" & sDATE & "#,#" & eDATE & "#,'" & IMAGE & "'," & ALLOW_C & "," & ALLOW_V & "," & HLITE & ", " & USE_VIEW & ")"
  5.             ELSE
  6.                 SQL = "INSERT INTO nm_tbl_news (fldTITLE, fldCONTENT, fldSUMMARY, fldACTIVE, fldAID, fldPOSTED, fldEXPIRES, fldIMAGE, fldALLOW_COMMENTS, fldALLOW_VOTING, fldHIGHLIGHT, fldUSE_VIEW) VALUES ('" & TITLE & "','" & CONTENT & "','" & SUMMARY & "'," & ACTIVE & "," & AGENT & ",'" & sDATE & "','" & eDATE & "','" & IMAGE & "'," & ALLOW_C & "," & ALLOW_V & "," & HLITE & ", " & USE_VIEW & ")"
  7.  
  8.             END IF 


As you can see, fldCreated was missing from the Access one too. But the data that i transferred using Bullzip, shows the fldCreated field with dates in. The only ones showing "null" are the 4 articles i added since ive had MySQL

Anyway, using the code above, it didn't add the article to the database, but returned the error above.

I don't think this is related, but when i transferred the data, i couldn't transfer using Bullzip, without leaving out the "default" values, whatever those are. When i unchecked that box, i could transfer the data. I don't think that has anything to do with this, but just in case, i thought i'd let you know.


an update: I just checked my access database, and it didn't have a "fldCreated " column, so i'm confused now. Did the transfer create this extra column or what?

Many thanks
Nov 17 '08 #3
Nicodemas
164 Recognized Expert New Member
to solve the variable undefined errors, just create Dim statements for all teh variables I added to the top of the page, underneath the include statements.
See if that clears up the issue
Dec 25 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3739
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB my filed "date" in table "experience" is like this: Y-m-d (2002-07-23). My fied`date` is date, NOT NULL with no default entry My form read well the date data depending the id, (pe. 30.02.2003), but when I submit a new date, I receive as result...
2
2107
by: Jasper Bryant-Greene | last post by:
I have a database of movie titles, with about 78,000 records, and a database of related people (directors, writers, actors/actresses etc.) with about 141,000 records. I display a random movie out of this database on each hit to my website's homepage. This worked fine when I had only a couple thousand movies, but now that the DB has grown, it seems to be taking a bit longer to process the page. My DB schema for each table:
0
1686
by: David Bordas | last post by:
Hi list, I've got a little bug with MySQL. I can insert a row into my table but this row will not appear in the table :( Server is under linux redhat, MySQL is 3.23.56 installed from binary tar.gz from MySQL team. Table Description : mysql> desc Log_Forums;
0
3955
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
2
1609
by: Jeffrey D Moncrieff | last post by:
I am trying to create a data base for colleting date for my research project. I have run in to a couple of problems and I need it fast ASAP I need it to be able to add data and edit them and view the data form a public site. I have not use mysql and php since 2003 I have created the date base with 2 tables 1 for a Jump Menu and on for the content. The contents is in a table called PR and I as soon as I enter the data and hit submit the web...
1
3386
by: jlee | last post by:
I'm pretty much a newbie on mysql, and I need some help. I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4 (i386) on a server hosting an active website. The site's developer uses his own php shopping cart to receive customer orders. The configuration was done via cPanel with no external modifications - which produced no protests when built, ran and connected with no
0
6638
by: Bucker | last post by:
Could someone view the following that I copied from phpMyAdmin and tell me from the statistics if are server is running OK? Does it look like we will have problems as more people hit our server? I'm not a db admin, so any help would be grateful. Regards,
1
1744
by: webandwe | last post by:
Hi The code below I took from a postgre file and convert it with a program to a mysql. Once i tried to import it to mysql it gave me an error and when i past in a php file to upload it trough a php file it stats I have loaded the information into the DB but i don't see any tables in the DB. Here is the code as it comes from my plain *.txt file. Any suggestions? CREATE TABLE categories ( record int(11) auto_increment NOT NULL, ...
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10910
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10654
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10297
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7833
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7021
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5683
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4066
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.