
iamnothyper
Members-
Posts
12 -
Joined
-
Last visited
iamnothyper's Achievements

Newbie (1/5)
0
Reputation
-
got it, the problem was the \r
-
i tried the select with that to test it but still an empty set D; what's wrong with thisss and the select result is still the same
-
i also just did UPDATE stocks SET ticker = trim(ticker); in case but i get the same result?
-
i used this to load it:LOAD DATA LOCAL INFILE "stock_data.csv" INTO TABLE stocks FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; and i just did this to check: SELECT close FROM stocks WHERE ticker = "JCP\n"; to test that and i still got an empty set?
-
hi, my query is: SELECT close FROM stocks WHERE the_date = '2013-04-10' AND ticker = 'JCP'; i get an empty set. i have since realized the problem lies with the ticker field because using just the date is fine. so i did SELECT * FROM stocks; +----------+------------+--------+--------+--------+--------+-----------+-----------+--------+ | stock_ID | the_date | open | high | low | close | volume | adj_close | ticker | +----------+------------+--------+--------+--------+--------+-----------+-----------+--------+ | 1 | 2013-04-26 | 409.81 | 418.77 | 408.25 | 417.20 | 27289200 | 417.20 | AAPL | 2 | 2013-04-25 | 411.23 | 413.94 | 407.00 | 408.38 | 13713700 | 408.38 | AAPL | 3 | 2013-04-24 | 393.54 | 415.25 | 392.50 | 405.46 | 34630400 | 405.46 | AAPL | 4 | 2013-04-23 | 403.99 | 408.38 | 398.81 | 406.13 | 23294100 | 406.13 | AAPL | 5 | 2013-04-22 | 392.64 | 402.20 | 391.27 | 398.67 | 15340900 | 398.67 | AAPL | 6 | 2013-04-19 | 387.97 | 399.60 | 385.10 | 390.53 | 21749700 | 390.53 | AAPL | 7 | 2013-04-18 | 404.99 | 405.79 | 389.74 | 392.05 | 23783300 | 392.05 | AAPL | 8 | 2013-04-17 | 420.27 | 420.60 | 398.11 | 402.80 | 33735300 | 402.80 | AAPL | 9 | 2013-04-16 | 421.57 | 426.61 | 420.57 | 426.24 | 10890600 | 426.24 | AAPL | 10 | 2013-04-15 | 427.00 | 427.89 | 419.55 | 419.85 | 11318300 | 419.85 | AAPL | 11 | 2013-04-12 | 434.15 | 434.15 | 429.09 | 429.80 | 8521900 | 429.80 | AAPL | 12 | 2013-04-11 | 433.72 | 437.99 | 431.20 | 434.33 | 11727300 | 434.33 | AAPL | 13 | 2013-04-10 | 428.10 | 437.06 | 426.01 | 435.69 | 13415800 | 435.69 | AAPL | 14 | 2013-04-26 | 8.35 | 8.36 | 8.26 | 8.27 | 15141900 | 8.27 | AA | 15 | 2013-04-25 | 8.42 | 8.50 | 8.34 | 8.39 | 18396000 | 8.39 | AA | 16 | 2013-04-24 | 8.12 | 8.45 | 8.12 | 8.41 | 22031100 | 8.41 | AA | 17 | 2013-04-23 | 8.12 | 8.17 | 8.04 | 8.12 | 16255700 | 8.12 | AA | 18 | 2013-04-22 | 8.12 | 8.15 | 7.99 | 8.11 | 14758200 | 8.11 | AA | 19 | 2013-04-19 | 8.09 | 8.11 | 8.00 | 8.08 | 15661700 | 8.08 | AA | 20 | 2013-04-18 | 8.00 | 8.08 | 7.90 | 8.03 | 19079900 | 8.03 | AA | 21 | 2013-04-17 | 8.04 | 8.08 | 7.93 | 7.96 | 27240400 | 7.96 | AA | 22 | 2013-04-16 | 8.08 | 8.20 | 8.06 | 8.10 | 22820600 | 8.10 | AA | 23 | 2013-04-15 | 8.14 | 8.17 | 8.01 | 8.04 | 32459300 | 8.04 | AA | 24 | 2013-04-12 | 8.30 | 8.32 | 8.17 | 8.22 | 21450400 | 8.22 | AA | 25 | 2013-04-11 | 8.30 | 8.40 | 8.27 | 8.32 | 13180400 | 8.32 | AA | 26 | 2013-04-10 | 8.43 | 8.47 | 8.30 | 8.31 | 20827200 | 8.31 | AA | 27 | 2013-04-26 | 31.90 | 31.98 | 31.45 | 31.79 | 47799300 | 31.79 | MSFT | 28 | 2013-04-25 | 31.71 | 32.84 | 31.54 | 31.94 | 110688300 | 31.94 | MSFT | 29 | 2013-04-24 | 30.62 | 31.92 | 30.60 | 31.76 | 90946600 | 31.76 | MSFT | 30 | 2013-04-23 | 30.70 | 30.90 | 30.38 | 30.60 | 59082400 | 30.60 | MSFT | 31 | 2013-04-22 | 30.30 | 31.18 | 30.27 | 30.83 | 137904000 | 30.83 | MSFT | 32 | 2013-04-19 | 29.62 | 30.24 | 29.61 | 29.77 | 99790700 | 29.77 | MSFT | 33 | 2013-04-18 | 28.95 | 28.98 | 28.50 | 28.79 | 56841500 | 28.79 | MSFT | 34 | 2013-04-17 | 28.85 | 29.04 | 28.60 | 28.83 | 52840700 | 28.83 | MSFT | 35 | 2013-04-16 | 28.90 | 29.14 | 28.70 | 28.97 | 52797300 | 28.97 | MSFT | 36 | 2013-04-15 | 28.65 | 28.98 | 28.51 | 28.69 | 56332900 | 28.69 | MSFT | 37 | 2013-04-12 | 28.85 | 29.02 | 28.66 | 28.79 | 62886300 | 28.79 | MSFT | 38 | 2013-04-11 | 29.10 | 29.20 | 28.73 | 28.94 | 130907100 | 28.94 | MSFT | 39 | 2013-04-10 | 29.57 | 30.32 | 29.52 | 30.28 | 71058300 | 30.28 | MSFT | 40 | 2013-04-26 | 21.39 | 21.53 | 21.25 | 21.40 | 17348300 | 21.40 | MS | 41 | 2013-04-25 | 21.56 | 21.81 | 21.39 | 21.43 | 18496600 | 21.38 | MS | 42 | 2013-04-24 | 21.66 | 21.78 | 21.40 | 21.45 | 17955700 | 21.40 | MS | 43 | 2013-04-23 | 20.97 | 21.73 | 20.91 | 21.61 | 23437700 | 21.56 | MS | 44 | 2013-04-22 | 20.61 | 20.88 | 20.53 | 20.71 | 16156600 | 20.66 | MS | 45 | 2013-04-19 | 20.37 | 20.63 | 20.16 | 20.58 | 24644100 | 20.53 | MS | 46 | 2013-04-18 | 21.35 | 21.47 | 20.31 | 20.31 | 47193400 | 20.26 | MS | 47 | 2013-04-17 | 21.54 | 21.83 | 20.86 | 21.47 | 45475800 | 21.42 | MS | 48 | 2013-04-16 | 21.81 | 21.86 | 21.19 | 21.85 | 21839800 | 21.80 | MS | 49 | 2013-04-15 | 21.75 | 22.25 | 21.41 | 21.48 | 22458100 | 21.43 | MS | 50 | 2013-04-12 | 22.09 | 22.23 | 21.54 | 21.82 | 25150400 | 21.77 | MS | 51 | 2013-04-11 | 22.28 | 22.63 | 22.24 | 22.27 | 14692800 | 22.22 | MS | 52 | 2013-04-10 | 21.89 | 22.53 | 21.87 | 22.22 | 17467300 | 22.17 | MS | 53 | 2013-04-26 | 16.15 | 17.58 | 15.86 | 17.00 | 56658800 | 17.00 | JCP | 54 | 2013-04-25 | 15.26 | 15.56 | 15.20 | 15.24 | 10840900 | 15.24 | JCP | 55 | 2013-04-24 | 15.48 | 15.60 | 15.15 | 15.19 | 7242100 | 15.19 | JCP | 56 | 2013-04-23 | 15.19 | 15.73 | 14.95 | 15.45 | 14552800 | 15.45 | JCP | 57 | 2013-04-22 | 15.36 | 15.80 | 15.31 | 15.54 | 13453300 | 15.54 | JCP | 58 | 2013-04-19 | 15.20 | 15.39 | 14.85 | 15.26 | 17094800 | 15.26 | JCP | 59 | 2013-04-18 | 14.97 | 15.29 | 14.83 | 15.16 | 29205100 | 15.16 | JCP | 60 | 2013-04-17 | 15.07 | 15.13 | 14.58 | 14.77 | 17433900 | 14.77 | JCP | 61 | 2013-04-16 | 14.59 | 15.42 | 14.45 | 15.19 | 28576300 | 15.19 | JCP | 62 | 2013-04-15 | 14.43 | 15.15 | 14.27 | 14.39 | 32590400 | 14.39 | JCP | 63 | 2013-04-12 | 15.01 | 15.03 | 14.24 | 14.62 | 36423900 | 14.62 | JCP | 64 | 2013-04-11 | 14.19 | 15.12 | 14.16 | 14.86 | 27459000 | 14.86 | JCP | 65 | 2013-04-10 | 14.03 | 14.36 | 13.55 | 14.09 | 34677000 | 14.09 | JCP +----------+------------+--------+--------+--------+--------+-----------+-----------+--------+ Then I did SELECT ticker FROM stocks; +--------+ | ticker | +--------+ |APL |APL |APL |APL |APL |APL |APL |APL |APL |APL |APL |APL |APL | | | | | | | | | | | | | |SFT |SFT |SFT |SFT |SFT |SFT |SFT |SFT |SFT |SFT |SFT |SFT |SFT | | | | | | | | | | | | | |P |P |P |P |P |P |P |P |P |P |P |P |P +--------+ can someone please tell me what the hell is going on with the ticker column? and, this is imported from a csv file, if that means anything.
-
this is the output on the page: Connected successfully Selected successfully Transaction Has Been Added: Client Name: Array Date of Transaction: 2013-04-10 Stock Ticker: JCP Number of Shares: 10 Price of Stock: Notice: Undefined variable: result in /web/rl1426/8/transaction_added.php on line 65 Warning: mysql_free_result() expects parameter 1 to be resource, null given in /web/rl1426/8/transaction_added.php on line 65 and this is the view source <html> <head> <link href="transaction.css" rel="stylesheet" type="text/css" /> <title>Transaction Added</title> </head> <small><small><small>Connected successfully</small></small></small><br /> <small><small><small>Selected successfully</small></small></small><br /> <h1>Transaction Has Been Added:<br></h1><hr /> <h2> Client Name: Array <br> Date of Transaction: 2013-04-10 <br> Stock Ticker: JCP <br> Number of Shares: 10 <br> Price of Stock: <br> Notice: Undefined variable: result in /web/rl1426/8/transaction_added.php on line 65 Warning: mysql_free_result() expects parameter 1 to be resource, null given in /web/rl1426/8/transaction_added.php on line 65 </body> </html>
-
this is the entire code, i changed some stuff and the undefined variable messages aren't showing for $price and $fullname anymore but they are still not printing. I tried using echo too but that doesn't work either. the only actual error i'm getting is the result of a query i commented off. Notice: Undefined variable: result in /web/rl1426/8/transaction_added.php on line 65 Warning: mysql_free_result() expects parameter 1 to be resource, null given in /web/rl1426/8/transaction_added.php on line 65 but the issue is that $fullname is printing out as "Array" and $price is printing out as nothing. I don't know what errors you want me to post up. <html> <head> <link href="transaction.css" rel="stylesheet" type="text/css" /> <title>Transaction Added</title> </head> <?php include ('/home/rl1426/config.php'); $db_link = mysql_connect($db_server, $db_user, $db_password); if (!$db_link) die("Could not connect: " . mysql_error()); print( nl2br("<small><small><small>Connected successfully</small></small></small>\n")); $db_selected = mysql_select_db($db_name, $db_link); if (!$db_selected) die("Can't use \"$db_name\" : " . mysql_error()); print( nl2br("<small><small><small>Selected successfully</small></small></small>\n")); /* setting variables from HTML */ $the_date = $_POST['the_date']; $ticker = $_POST['ticker']; $shares = $_POST['shares']; $client_ID = $_POST['client_ID']; $buy = $_POST['buy']; $dataCheck = 1; $trans_ID = "NULL"; if (empty ($shares)) { print("<h2>Please input how many shares of stock you would like to buy/sell.</h2>\n"); $dataCheck = 0; } if ($dataCheck > 0) { /* Performing SQL SELECT price query*/ $query1 = "SELECT close FROM stocks WHERE the_date = '$the_date' AND ticker = '$ticker' "; $result1 = mysql_query($query1) or die("Query failed : " . mysql_error()); $price = mysql_fetch_assoc($result1); $query2 = "SELECT CONCAT(fname,' ',lname)FROM clients WHERE client_ID = '$client_ID' "; $result2 = mysql_query($query2) or die("Query failed : " . mysql_error()); $fullname = mysql_fetch_assoc($result2); /* Printing results in HTML */ print("<h1>Transaction Has Been Added:<br></h1><hr />\n"); print("<h2>\t Client Name: $fullname <br>\n"); print("\t Date of Transaction: $the_date <br>\n "); print("\t Stock Ticker: $ticker <br>\n"); print("\t Number of Shares: $shares <br>\n"); print("\t Price of Stock: $price <br>\n"); } else { print("<p><h2>Error. Please try again.</p>\n</h2>"); } /* Performing SQL INSERT query $query4 = "INSERT INTO transactions (trans_ID,the_date,ticker,shares,price,client_ID,buy) VALUES (\"$trans_ID\",$the_date,\"$ticker\",$shares,$price,$client_ID,$buy)"; $result = mysql_query($query4) or die("Query failed : " . mysql_error()); */ /* Free resultset */ mysql_free_result($result); /* Closing connection */ mysql_close($db_link); ?> </body> </html>
-
it just says Undefined variable price/buysell/fullname... etc etc on the webpage when i try to print it what i want to do ultimately is insert the value $price into a table and print out the values for all of them. $price comes from a query of two variables taken from a php form on a previous page. and $fullname/$buysell are supposed to be kinda link concats of two other variables so i can print the info for the user? Debugging? well not really because my only problem is with how i'm handling these variables i think? iunno, im just really confused at this point >< thanks for helping me!
-
i did this $query1 = "SELECT close FROM stocks WHERE the_date = '$the_date' AND ticker = '$ticker' "; $result1 = mysql_query($query1) or die("Query failed : " . mysql_error()); $price = mysql_fetch_assoc($result1); $query2 = "SELECT CONCAT(fname,' ',lname)FROM clients WHERE client_ID = '$client_ID' "; $result2 = mysql_query($query2) or die("Query failed : " . mysql_error()); $fullname = mysql_fetch_assoc($result2);and now i get an undefined variable error.i need to insert $price later and print out both $price & $buysell
-
i looked and no matter what variations of fetch/assoc i try to use i cant seem to get it working. either i break the code or nothing gets printed at all, or just "resource id#4"
-
hi! thanks, that stopped the JCP error but when I do this to check print("\t Price of Stock: $price <br>\n"); I get "Price of Stock: Resource id #4" ? How do i get it to print the actual price? i'm also getting the same problem for $fullname and $buysell. i thought setting them equal to query stores the value? $query2 = "SELECT CONCAT(fname,' ',lname)FROM clients WHERE client_ID = '$client_ID' "; $fullname = mysql_query($query2) or die("Query failed : " . mysql_error()); $query3 = "SELECT CASE buy WHEN 0 THEN 'Sell' WHEN 1 THEN 'Buy' END FROM transactions "; $buysell = mysql_query($query3) or die("Query failed : " . mysql_error()); and i'm getting this error message at the bottom of my screen. Query failed : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id #4,1,1)' at line 2
-
Hi! I'm doing an assignment for school and I need help finding the error in my code. It's a two part process where a php form grabs the data and inserts the result into mysql. i'll try to only post up the bits and pieces that are relevant. here's the form part. as far as i know this part is working fine, but it might be helpful to see it? $query2 = "SELECT ticker FROM tickers ORDER BY ticker "; $result2 = mysql_query($query2) or die("Query failed : " . mysql_error()); print("Stock Ticker:<br />"); print("<select name=ticker>"); while ($line2 = mysql_fetch_array($result2)) { print("<option value=\"$line2[0]\">$line2[0]</option>\n"); } print("</select>"); here is the result part. its linked via: <form action="transaction_added.php" method="post"> $ticker = $_POST['ticker']; $dataCheck = 1; if ($dataCheck > 0) { /* Performing SQL SELECT query */ $query1 = "SELECT close FROM stocks WHERE the_date = $the_date AND ticker = $ticker "; $price = mysql_query($query1) or die("Query failed : " . mysql_error()); the error message i'm getting on the webpage is: Query failed : Unknown column 'JCP' in 'where clause' JCP is the ticker value in this case. I'm not sure why it's taking JCP to be the column name? What am I doing wrong here? Thanks!