SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 63
  1. #26
    SitePoint Zealot gidday's Avatar
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi ulthane

    Read up on Access dB data types (I assume you are using access). When you do the answer will be very clear.

    And here is a link where you can do the reading. Have a look. http://www.w3schools.com/SQL/sql_datatypes.asp
    Joe
    "All that is necessary for the triumph of evil
    is that good men do nothing."

  2. #27
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks, i read and got my problem solved

  3. #28
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Siteguru
    Easiest way is to have an admin page which lists all the animals awaiting adoption, and against each one have a checkbox whose value is the fileID. When you submit the form you capture the fileID values then run an SQL query to simply update the Animals table to set the adoptionstatus to 2.

    e.g. get all the IDs and group them as a comma-delimited string of values (e.g. IDs = "1,3,4"). Then you could run a query such as below:

    sSQL = "UPDATE Animals SET adoptionstatus='2' WHERE fileID IN (" & IDs & ")"
    Hey, can u give me more info on how to make those checkbox and connect them to the fileID coluum in the DB like u said? i dont really know how to do that, altho i've got the admin page that reads all the info from the DB and displays it ready now i just need help with the editing stuff...

    Thanks
    Attached Images Attached Images

  4. #29
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Create this as test.asp, put it on your web server then call it in your browser.

    Code ASP:
    <%
    sCB = Request.Form ("cb")
    If Isempty (sCB) Then Response.Write "<P>NADA</P>"
    Response.Write "<P>" & sCB & "</P>"
    %>
    <form method="POST">
    <input type="checkbox" name="cb" value="1"><br>
    <input type="checkbox" name="cb" value="2"><br>
    <input type="checkbox" name="cb" value="3"><br>
    <input type="checkbox" name="cb" value="4"><br>
    <input type="checkbox" name="cb" value="5"><br>
    <input type="submit" name="submit" value="Submit">
    </form>
    See how the checkboxes all have the same name, yet when you check the boxes and click submit you see a comma-delimited list? What did my earlier example show?
    Ian Anderson
    www.siteguru.co.uk

  5. #30
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the form it does work on with my table but i dont know where should i put that line to edit the status ?

    This line u gave me acutally,
    Code:
    sSQL = "UPDATE Animals SET (adoptionstatus='2') WHERE fileID IN (" & sCB & ")"

  6. #31
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    When you submit the form (i.e. the form that surrounds the table containing the list of animals awaiting adoption, on that admin page), in the ASP page that this form submits to is where you use that SQL query.

    This is all pretty basic stuff - it seems you maybe need to learn some of the fundamentals of web page design, how they work, before you start doing things like you are trying to achieve. Learn to walk before you try to run.
    Ian Anderson
    www.siteguru.co.uk

  7. #32
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    haha yeah, that was kinda basic, newbie me
    Well honestly im learning everything my self with the help of some guides like Tizag's and forums etc
    Anyways, i got that done Add, delete, edit pets works nicely.

    Now i wanna ask another thing, on my homepage i got a date (every 2 weeks we got adoption days, so i need to update that date every 2 weeks)
    How do i do that, if the date is in the middle of the page? like this:

    Code:
    ...
    <center><b><font size="6">ברוכים הבאים!</font></b>
    <br />
    <b><font size="6">יום האימוץ הבא:</font></b>
    שבת - 15.5.10    <-- Date line
    בין השעות 11:00 - 13:00 משתלת חזקיה, אשקלון</center>
    <br />
    ...
    Thanks again

  8. #33
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    See the Date functions. (You should really get/bookmark a language reference for ASP/VBScript - Oh look! Here is one ).
    Ian Anderson
    www.siteguru.co.uk

  9. #34
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hey again pple i had alittle break because of exams and now im back to my site project
    I need help with that Date thingy, i've got it working, but i wanna know how do i make it so when a new date got uploaded to the DB, it will replace the current date, and not added to a new coluum in the DB.
    Thanks in advance

  10. #35
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It depends on how your database is structured. Logically the record that contains the date (and probably other data) should have an ID field. If it does then (in general terms) ...

    Code:
    UPDATE TableName SET DateField=#NewDate# WHERE IDField=IDvalue
    Ian Anderson
    www.siteguru.co.uk

  11. #36
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Getting an error when trying to run, i've tried running it in every way possible and still didnt work...
    c.execute line gives error
    Code:
     			set c=server.createobject("adodb.connection")
    
    			c.Open 	"Driver={Microsoft Access Driver (*.mdb)};" &_
    					"Dbq=" & Server.MapPath("Database.mdb") & ";"
    
    			sSQL = "update Dates set Desc=desc1 where FileID=1"
    			c.execute sSQL
    			
    		
     	    c.Close
     	    Set c = Nothing
    			
    		response.redirect "home.asp"

  12. #37
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    so can any1 help me out with this please ? that still doesn't work out for me..

  13. #38
    SitePoint Zealot gidday's Avatar
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi ulthane

    You need to help us a bit here. What is the error?
    Joe
    "All that is necessary for the triumph of evil
    is that good men do nothing."

  14. #39
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

  15. #40
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is a common error.

    You have a field name called Desc ... but DESC is also a command in SQL. Either change the field name, or ...

    Code:
    sSQL = "update Dates set [Desc]='" & desc1 & "' where FileID=1"
    Note: the [] bit solves the initial error. I have also assumed that desc1 is a variable containing the data to be updated, so I have shown how you should do this in the ASP code. Text values need to be surrounded by ' '.

    PS: I would recommend using the Jet SQL driver rather than the Access driver. More web hosts are likely to have this than the Access driver, and the Access driver is very old.

    http://www5.brinkster.com/hiflyer/db/dbtest.asp
    Ian Anderson
    www.siteguru.co.uk

  16. #41
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the solution that prob is solved but when one problem is solved another one comes =)
    it says that it sent the info to the DB but it doesnt do anything, the desc field is blank

  17. #42
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    As with everything, debug.

    Code:
    sSQL = "update Dates set [Desc]='" & desc1 & "' where FileID=1"
    Response.Write sSQL
    That should show in the browser exactly what SQL command is being executed.

    Remember, my SQL code was simply an example - you need to be using YOUR actual SQL code.

    This is all basic stuff that you need to get your head around - we can't baby-walk you through building the application.
    Ian Anderson
    www.siteguru.co.uk

  18. #43
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well, again, im learning everything by myself, from guides / forums / anywhere else possible, thats why the questions im asking might be basic, but where else i can ask them if not here?

    anyways....i've ran into another prob (jeez that just never ends ) when i typed a certain date to add, the response write shown it correctly (For example 15/5/5) but in the DB itself its posting something like "4Er73573F"...How to solve that thing? Thanks in advance

  19. #44
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If it is an Access database file, and the field is set for Date datatype, and you are applying the date in the correct format (of which 15/5/5 is unusual .... 5th May 2015?) then it should work OK.

    Remember that date values in Access are delimited by # #

    Code:
    sSQL = "UPDATE Table SET DateField=#2010/06/21#"
    Regarding my "basic stuff" comment - several of your questions have been of the same theme, suggesting that the lessons are not being learnt. I don't mean to sound harsh, but there's a limit to how much time people can spend helping you - particularly if it looks like you're not putting in the effort to try and help yourself. (I'm not saying you aren't putting in the effort - just that it can come across like that).

    http://articles.sitepoint.com/articl...mmunity-member
    Ian Anderson
    www.siteguru.co.uk

  20. #45
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    yep, my questions do sound the same, but they are not the same at all, things that are working for certain pages can do millions of problems for another and this date page (which needs to be the easiest compared to what i've did before) does the most problems for me, and im also surprised...

    Im adding many things to my website everytime an idea comes to my mind, most of them are learned from here, and u do not know about them because i've already done them alone. (thanks to ur help mostly, ofc)

    Back to that date thingy, it isnt declared as "Date" type on my DB, just text to make it easier and avoid unnesassry problems.. (maybe im wrong here..)
    However i've tried typing a few things and my last try was typing just a '/' and it seems like this is what gives the error...when im typing numbers only it uploads fine, when i tried this, thats the error i get:

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '/'.

    This is how the asp page looks like atm:
    Code:
    <&#37;
    date2 = Request.Form("date1")
         set c=server.createobject("adodb.connection")
    
         c.Open 	"Driver={Microsoft Access Driver (*.mdb)};" &_
    		"Dbq=" & Server.MapPath("Database.mdb") & ";"
    
    sSQL = "UPDATE Dates SET AdoptDates=" & date2 & " WHERE fileID=1"
    c.Execute sSQL
    		
     	c.Close
     	Set c = Nothing
     	    
     	    Response.Redirect "home.asp"
    %>
    So its seems like there's a problem with the page itself or what is it? :/
    Thanks again for the help, and sorry if that was too much, but as u see, those erorrs are freaking me out

  21. #46
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What is the datatype of the AdoptDates field? Your SQL string is expecting it to be a number ... if it is a text field then you need to use the ' ' delimiters. (That's why it is throwing an error when it sees the / character - it is trying to do a mathematical calculation and doesn't know how to resolve it).

    Code:
    sSQL = "UPDATE Dates SET AdoptDates='" & date2 & "' WHERE fileID=1"
    But I'd recommend using the Date datatype - it makes future uses of the data in that field much easier to implement. (e.g. you want to report how many animals were adopted between certain dates - easy to do with a Date datatype, difficult with a Text datatype).

    Question: is this website/application going to be accessible via the internet? If yes then read up about SQL Injection ... your coding thus far appears to have little or no validation of user data entry.
    Ian Anderson
    www.siteguru.co.uk

  22. #47
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks, got my date function working also i wont need anything else to do with it, so text field for it should be enough for now.

    to answer ur question, i have no plan of making this site public, but if it will then ill make sure to read about security stuff etc for now its just for learning purposes, together with the things i like the most: pets

  23. #48
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello again everyone
    I've got 2 new questions i would like to ask

    1) i've been working on a few functions to check my upload form page, to see if all fields were filled correctly etc, however, when i submit the form, it does gives the needed error if it was filled incorrectly, but still sends to the next page, what am i missing to solve it?
    JS form
    Code:
      <script type="text/javascript" language="javascript">
       function checkfrm()
         {
          if(document.pets.desc1.value=="")
            {
             alert("יש למלא תיאור חיית המחמד");
             document.Pets.desc1.focus();
             return false;
            }
          if(document.pets.adoptionstatus1.value=="0")
            {
             alert("יש למלא מצב אימוץ");
             return false;
            }
          if (document.pets.animaltype1.value == "0") 
            {
                alert("יש למלא סוג חיית המחמד");
                return false;
            }
            if (document.pets.type1.value == "0") {
                alert("יש למלא מין/כמות עבור חיית המחמד");
                return false;
            } 
           
       return true;
     }
     </script>
    the form itself

    Code:
    <FORM name="pets" method="post" encType="multipart/form-data" action="Database_Save.asp" onreset="return confirm('האם אתה בטוח?')" onsubmit="return checkfrm()">
    <br />
    <table border="2" align="center" bgcolor="white">
        <tr>
         <td bgcolor="#e8e8e8"> סוג חיית מחמד - 1 לכלב 2 לחתול 3 לכלב חודש 4 כלב חודש לדף הבית </td>
         <td> <select name="AnimalType1">
                <option value="0"> בחר </option>
                <option value="1"> 1 </option>
                <option value="2"> 2 </option>
                <option value="3"> 3 </option>
                <option value="4"> 4 </option>
              </select>
         </td>
        </tr>
    <tr>
         <td bgcolor="#e8e8e8"> מצב אימוץ - 1 זמין 2 לא זמין </td>
         <td> <select name="AdoptionStatus1">
                <option value="0"> בחר </option>
                <option value="1"> 1 </option>
                <option value="2"> 2 </option>
              </select>
         </td>
        </tr>
      <tr>
         <td> תמונת חיית המחמד </td>
         <td bgcolor="#e8e8e8"> <input type="file" name="file1" /> </td>
        </tr>
      <tr>
         <td> תיאור חיית המחמד </td>
         <td bgcolor="#e8e8e8"> <input dir="ltr" type="text" name="desc1" /> </td>
        </tr>
        <tr>
         <td> מין/כמות - 1 זכר 2 נקבה 3 רבים</td>
           <td> <select name="type1">
                <option value="0"> בחר </option>
                <option value="1"> 1 </option>
                <option value="2"> 2 </option>
                <option value="3"> 3 </option>
              </select>
         </td>
        </tr>
      <tr>
         <td> <INPUT type="submit" value="שלח"/> </td>
         <td bgcolor="#e8e8e8"> <input type="reset" value="נקה"/> </td>
        </tr>
        </table>
        </FORM>
    2) if i got some pictures of the same pet i would like to upload to the same coluum in the table, what do i need to add to my upload form to get it done?
    (the form above)

    The form containing the uploaded pictures:
    Code:
    <%
    sSQL = "SELECT * FROM Animals WHERE (adoptionstatus= '1')  AND (animaltype= '1')  ORDER BY fileID DESC"
    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("Database.mdb")
    Set oRS = oConn.Execute (sSQL)
    If Not oRS.EOF Then
    %>
    <table align="center" style="width: 650px;margin-bottom:10px;" border="5">
    <%
      Do While Not oRS.EOF
        sImage = oRS("FileID")
        sDesc = oRS("Desc")
    %>
      <tr>
        <td valign="middle" align="center"><a href="Database_Download.asp?FileID=<%=sImage%>"<img border="0" width="350" height="390" src="Database_Download.asp?FileID=<%=sImage%>" /></a></td><td align="right" dir="rtl"><%=sDesc%></td>
      </tr>
    <%
        oRS.MoveNext
      Loop
    %>
    </table>
    <%
    Else
      Response.Write "<p>No images to display.</p>"
    End If
    Set oRS = Nothing
    oConn.Close
    Set oConn = Nothing
    %>
    If u need to see anything more tell me and ill post

    Thanks

  24. #49
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Check that you're not getting any Javascript errors - these will stop the script and so not act on the return false statement (which is what is supposed to stop the form submitting).

    I use the Web Developer addon in Firefox as it reports any scripting errors. You can also try Firebug.

    PS - this is the ASP forum. You'll get better answers in the Javascript forum for Javascript questions.
    Ian Anderson
    www.siteguru.co.uk

  25. #50
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok let me check and reply you. thanks


Bookmarks

Posting Permissions

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