Jump to content

ameliabob

Members
  • Posts

    218
  • Joined

  • Last visited

Posts posted by ameliabob

  1. I cannot find an example of how to process multiple selections from an option

    [code]

    <!DOCTYPE HTML
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <head>
         <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="/dunes.css" media="screen" />
    </head>
    <script type="text/javascript">

    function DoCustomSearch(){
        n = document.getElementById("fieldNames").value;
    alert("selected fieldNames are "+n);    
     alert(s);
    }

    function ShowAdvancedQueryWindow(){

            s += "<select id='fieldNames' name='fieldNames' size='10' multiple >";
                s +=    "<option value='recNo'>Record Number</option>";
                s +=    "<option value='oName'>Listing Name</option>";
                s +=    "<option value='stNumber'>Street Number</option>";
                s +=    "<option value='stName'>Street Name</option>";
                s +=    "<option value='telno'>Telephone number</option>";
                s +=     "<option value='email'>email</option>";
                s +=    "<option value='showTel'>Show Telno</option>";
                s +=    "<option value='showEmail'>Show email</option>";
                s +=    "<option value='blastEmail'>BlastEmail</option>";
                s +=    "<option value='password'>Password</option>";
            s += "</select>"

            s += "<button type=button onclick='DoCustomSearch()'>Do Search</button>";
          
        document.getElementById('mainBody').innerHTML = s;
          }

    </script>
    <body onload="ShowAdvancedQueryWindow()">
       
        
    <div id="mainBody" >

    </div>

    </body>
    </html>

    [\code]

    If I select multiple options how do I know which of these are selected when I go to  "DoCustomSearch()"?

     

  2. I would like to know how I could see the calling sequence so I could determine how to precede.  in the first instance the calling sequence goes to the w3schools home; but the  second sequence goes to the java script and doesnt' go to the home.  Both of these are called from the address bar.

  3. Just to close the loop and in case others are looking for the same solution.

    I put in the line "echo 'Curl error: '.curl_error($ch);" and found that the error was SSL

    Then since putting the url in the browser didn't ask for any user name and password I added the following line to the curl options

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    The false parameter says something to the effect 'don't care about verifying' and allows it to do its thing.

    and it works!!

    Thanks for getting me on the right path.

    • Like 1
  4. OK, My error moving from Javascript to PHP. Fixed that and now get but still nothing back

    			 		Array ( [url] => https://api.iextrading.com/1.0/stock/market/batch?types=quote&filter=symbol,latestPrice,&symbols=T,IBM [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 20 [redirect_count] => 0 [total_time] => 0.156 [namelookup_time] => 0.047 [connect_time] => 0.11 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => 35.224.167.123 [certinfo] => Array ( ) [primary_port] => 443 [local_ip] => 10.0.0.167 [local_port] => 53785 ) 1alertjresult is alertresult is	

    putting the url  into a browser gives the answer result as
     
    {"T":{"quote":{"symbol":"T","latestPrice":32.97}},"IBM":{"quote":{"symbol":"IBM","latestPrice":145.23}}}
    Now what is missing??
  5. I am trying to get to a site with the following code:

    	        $syms ="T,IBM";
            $closeDict = array();    
            $url = "https://api.iextrading.com/1.0/stock/market/batch?types=quote&filter=symbol,latestPrice,&symbols="+$syms;
               $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    
        
               $jresult = curl_exec($ch);
               $info = curl_getinfo($ch);
            echo(print_r($info));
            echo("alertjresult is ".$jresult);
    	

    and several things are or are not happening. 

    1) the url doesn't get put into the header

    2) There is no response Notice the alerts at the end.

    I seem to recall reading that there is an option to set when accessing a https site.  However there is no password or other sign in function.  If you cut and paste the url into a browser it operates just fine.

    What I have I overlooked??

    [code}]

    Array ( => http://0/ [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 1.594 [namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 ) 1alertjresult is alertresult is

    [/code]

  6. I have the following code

    	    cur.execute("select symbol,stopPrice from holdings order by symbol" )
        for row in cur:
            newSym =str(row[0])
            if(syms==""):
                    syms = newSym
            else:
                    syms += ","+newSym
    	   
    	    holdingStops = BuildMyDict(cur)
    	

    	def BuildMyDict(response):
        myDict = dict()
        print(str(response))
        for r in response:
            myDict[r[0]] = float(r[1])
        return myDict
    	

    When I get to the BuldMyDict it believes the cur has already completed.  Is there a command that will reset the iterator counter?

  7. I see many examples o dictionary used but I cannot find any that adds to an existing dictionary

    	a = dict()
    	a['fgh']=123
    	a['ghi'] = 345
    	

    Yields the error

        a['ghi']=345
    TypeError: 'str' object does not support item assignment

    Is it only possible to build it once and not add to it??

  8. I can see functions allowing the calculations of the difference between two dates but I cannot locate how to find the addition or subtraction of x number of days from a given date.

    Is there such a thing in python?

  9. In all the examples they all seem to create a table before accessing it. How would I go about accessing one that has already been created the following code

    	import sqlite3
    	conn = sqlite3.connect('earnings.db')
    cur = conn.cursor()
    DROP TABLE closed
    cur.execute('CREATE TABLE closed (rowId INTEGER PRIMARY KEY AUTOINCREMENT, nature TEXT)
    	

    This generates a Syntax Error with TABLE highlighted in Red.

    If I remove the DROP line then I get the error that the table already exists

    ?????

  10. I have been a user of SQL and am now trying to start up a private database using sqlite.

    There does not appear to be a corresponding tool like phpmyadmin that I can find.

    How can I display columns and contents.  There is a reference to ./tables and ./columns.  but I cannot find what these a part of.

    Are the usages the same whether I am using the python shell or the command line?

    That should get me started.

    Thanks

    sqlite

    Is this where (gasp) I would ask questions on starting up with sqlite.  I am trying to get a small project off the ground and find that some of the tutorials leave something to be desired as far as their examples are concerned.  Or are other forums somewhere?

  11. The tutorial look simple  and straight forward but when I run

    	>>> import mysql.connector
    >>> mydb = mysql.connector.connect(
      host="localhost",
      user="root"
      )
    	

    I get this error

    Traceback (most recent call last):
      File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mysql\connector\connection_cext.py", line 176, in _open_connection
        self._cmysql.connect(**cnx_kwargs)
    _mysql_connector.MySQLInterfaceError: Access denied for user 'root'@'localhost' (using password: NO)

     

    I never get to the cursor creation

  12. I am trying to install and start mysql under python.  I am not sure that this is the correct forum or not.  If not point me to the correct one.

    I am trying to run this query in the python environment but I am not sure what to import ahead of this code

    	import mysql
    CREATE TABLE closed(
    rowId INT NOT NULL auto_INCREMENT
    type ENUM("O","S")
    symbol VARCHAR(6)
    sellDate DATE
    qty INT
    source VARCHAR(50)
    daysHeld INT
    pl INT
    ) ENGINE=InnoDB
    	

    I keep getting the error "Invalid syntax" point to the word "TABLE"

    Thanx

     

  13. I am receiving a string and I can't see to get it into a dictionary..

    For example I have a string:

    [{"rowId": 21,"nature": "O","symbol": "TAL","qty": 10,"daysHeld": 0,"source": "Momentum","dayEntered": "2018-01-16","pl": -40},

    {"rowId": 22,"nature": "O","symbol": "SGMO","qty": 5,"daysHeld": 35,"source": "Lightning Trend","dayEntered": "2018-02-06","pl": 2300},

    {"rowId": 23,"nature": "O","symbol": "NVDA","qty": 10,"daysHeld": 61,"source": "Tactical Trader","dayEntered": "2018-02-09","pl": -15300},

    {"rowId": 24,"nature": "O","symbol": "ALGN","qty": 10,"daysHeld": 88,"source": "none","dayEntered": "2018-01-18","pl": -17100},

    {"rowId": 25,"nature": "O","symbol": "IMGN","qty": 10,"daysHeld": 67,"source": "Lightning Trend","dayEntered": "2018-02-08","pl": 460}]

    How do I make this into a dict?

    How would I retreive the 'dayentered ' data from the line with symbol ALGN?

     

    Thanx

  14. I am trying to get a url that returns a json file but nothing seems to work nor do I get any errors

    	<html>
    <body>
    <h1>Trial of getting url</h1>
    <?php
    echo "Hello World!";
    $url = "https://api.iextrading.com/1.0/stock/market/batch?types=quote&filter=symbol,companyName,latestPrice,latestSource&symbols=AMD,APVO,DHI,ERI,GERN,LUV,LX,NVCR,TAP,WAR";
    $url="https://www.espn.com";
    	$ans = fopen($url, "r");
    	?>
    	</body>
    </html>
    	

    It should return the following:

    AMD  
    quote  
    symbol "AMD"
    companyName "Advanced Micro Devices Inc."
    latestPrice 15.8
    latestSource "Close"
    APVO  
    quote  
    symbol "APVO"
    companyName "Aptevo Therapeutics Inc."
    latestPrice 5.54
    latestSource "Close"
    DHI  
    quote  
    symbol "DHI"
    companyName "D.R. Horton Inc."
    latestPrice 40.75
    latestSource "Close"
    ERI  
    quote  
    symbol "ERI"
    companyName "Eldorado Resorts Inc."
    latestPrice 44.25
    latestSource "Close"
  15. I am trying to execute the following code

    	            $qry = "DELETE FROM holdings WHERE 'rowId' = '".$row."'";
    echo("alertAhead of delete.  ".$qry);
                $result= mysqli_query($cxn,$qry)or die("FinishExit Delete failed. ".mysqli_error($cxn)."   *** Qry was ".$qry);
    	

    the $qry variable when filled out is    DELETE FROM holdings WHERE 'rowId' = '9'

    but the row is still in the database when I look at it with phpAdmin  and the die was not executed.

    If I run  a query "select from holdings where rowId = '9' it is still there.

    I have tried using a fictitious name in the delete and the die does work for that

    Where should I look from here?

  16. I received the error  code " #1114 - The table 'closed' is full " from phpmysql after adding a structure and then I think I closed the table.  When I go back and try to extend the table by adding more columns I get this error.  I have tried adding the columns by either using the phpmysql structure and by using the SQL command 'ALTER TABLE closed ADD daysHeld int' they both give me the table full.  I have only added one row into the table.

    Is the only answer to delete and start over??

  17. The whole function looks like this

    [code}

            $qry= "select * from holdings where 'pl' is not null order by 'symbol'ASC";
            $result = mysqli_query($cxn,$qry) or die("ShowExit didn't work. ".mysqli_error($cxn));
            if(mysqli_num_rows($result)==0){
                $s = "alertThere are no entries in the database that meet your criteria.  Try changing the search.";
            }else{
                $s = "resp <table id='t01' border='1' >";
                $s .= "<tr><th>Type</th><th>Symbol</th><th>Expire Month</th><th>Qty</th>";
                $s .= "</tr>";
                while($r=mysqli_fetch_array($result)){
                    $s .= "<td>".$r[nature]."</td>";
                    $s .= "<td";
                    $s .= " onclick=\"GetFinishedData('9')\" > ";
                    $s .= $r[symbol]."</td>";
                    if($r[nature]=="O")
                        $s .= "<td><center>".$r[expireMonth]."</td>";
                    else
                        $s .= "<td><center>n/a</td>";
                    $s .= "<td>".$r[qty]."</td>";        
                    
                    $s .= "</tr>";
                }    
                $s .= "</table>";

                echo($s);

    [/code]

     

     

×
×
  • Create New...