Jump to content

charlie321

Members
  • Content Count

    45
  • Joined

  • Last visited

Everything posted by charlie321

  1. OK It does parse an html file on my localhost server. So what changed the ability to parse an html file? Linux, php, windows? Just curious to find out why I can do it on localhost (workbench-windows) and not on linux-mariadb. Thanks.
  2. No.. Actually I have been saying that from the beginning of this thread. If I tried to pass this from the html file to the php file it passed nothing or 0. That was on my mariadb server. If I passed it on my localhost workbench server it worked. When I changed the html file to a php file ie test.php it worked on both servers. Like I said I'd love to know why even though I did find a work around. The original html and php scripts for this is in the original thread above.
  3. OK I have no idea why but I changed the html file to a php file and echoed the form. It actually works now on both the localhost and server. time() just would not pass from my html localhost script. I would love to know why. It might have something to do with the fact that my localhost is workbench and the server is mariadb. Or the server could be a newer version of php. Really appreciate the help and suggestions.
  4. OK I think I understand. You threw me off by calling the semi-colon a colon. Unfortunately that did not solve the problem.
  5. You are talking about a semi-colon not colon? You are talking about the php script? What specific line are you talking about?
  6. Could you please explain further? I think you were mistaken. But if you are certain you are correct about the colon please explain in detail.
  7. colon??? What are you talking about?
  8. Hi... I have a little form and php script where I am trying to pass date() and get the seconds it takes to fill out the form. This works fine on localhost which is window based, but does not work on my server which is linux. On my linux server a 0 or blank is showing in the passed field. Any ideas on what might be wrong? I believe tjis is some sort of a minor coding error but my server shows no errors. Here is the script: <html> <form method="POST" action="test_time.php"> <input type="hidden" name="tm" value="<?php echo time() ?>" /> <input type="text" name="Name" size="15" placeholder="Enter Name">&nbsp;&nbsp; <input type="submit" value="Go" name="Submit"> </form> </html> <?php date_default_timezone_set("America/New_York"); $name = ucwords(strtolower($_POST['Name'])); $st = $_POST['tm']; $formFilledInSeconds = time() - $st; echo $name."<br>"; echo "start time: ".$st."<br>"; echo "time: ".time()."<br>"; echo "seconds: " .$formFilledInSeconds."<br>"; ?>
  9. Yes that was the problem with the script which I finally figured out just after my last post. And then I realized this would work better. $stax = tax_invoice($state,$subtotal,$credit,$shipping); Blood dribbling down my head from the wall punches. Take care.
  10. This is the code that is calling the function: tax_invoice($state,$subtotal,$credit,$shipping); I wrote an example that should show what is happening. It does the exact same thing: <?php $stax = 0; $subtotal = 100; $ship = 15; echo (($subtotal+$ship) * .07). " This is outside the function Correct answer.<p>"; function example($subtotal,$ship,$stax) { $stax == (($subtotal+$ship) * .07); echo $stax . " This is inside the function. Wrong answer.<p>"; return $stax; } example($subtotal,$ship,$stax); ##calling function. Nothing there. echo " This is calling the function. Gives a null which is wrong."; ?> There is something I'm not getting. I would appreciate someone who knows php functions show me what I am doing wrong in the little script that describes the problem. I'd really appreciate it!
  11. I have posted a modified function above already. Please reference that. Below is the code that woks fine as a non- function: if ($state == "FL") { $stax = ($subtotal-$credit+$shipping) * .07; } As I have said, this works but is redundant as it is presented several times throughout the code. Thus my wanting to make it a function.
  12. I had taken the FL if statement out to see if that was the problem. But did not work that way either. This works fine in code. Basically am trying to get the result as sales tax for the state of Florida using subtotal of invoice, credit, and shipping totals. Something within the function is preventing that from happening as it never gives anything but 0 for sales tax variable ($stax) As I said it works fine in code. I believe it is something to do with the variables not passing into or out of the function. I have worked with functions in other languages with no problems passing variables. Has to be something I am missing.
  13. I tried this which I thought might be what you were getting at but no success. More help please. function tax_invoice($subtotal,$credit,$shipping,$state) { if ($state == "FL") { $stax = ($subtotal-$credit+$shipping) * .07; return $stax; } }
  14. Trying to understand php functions. function tax_invoice() { if ($state == "FL") { $stax = ($subtotal-$credit+$shipping) * .07; } } #call function: tax_invoice(); I have tried different variations including in script, on own functions program, using return, adding variables, etc. Nothing seems to work unless I use it as a non-function in code. Please help.
  15. Sorry you feel that way. I guess he will think for himself. It's not that I am ignoring anything. What I have done so far is working although I'm sure it isn't proper. I guess I'm not a proper guy. What works for me works. I'm just learning how to do things. I don't know arrays at all and more or less I am fumbling through this. I don't know what question you are talking about but I'm only looking for the answers that will work for me the way I do things. And I do realize I might turn people off for this. But to be honest I find responses from people on this board in particular to be somewhat insulting and ignorant on their own. Not all. There are some cool people on here. But there are also some pompous type people here. There is no understanding that not everyone on this board has been doing this for a very long time. There are people who are trying their best to get through this. There are people who get overwhelmed by head banging problems and might miss some posts. There are people who probably would rather not come to this board and ask questions only to be ridiculed by php gods. The purpose of this board is to help others. You sound like a professor I had in college who was very intelligent, but he didn't understand that he had no clue how to help others. This I feel is a very unfriendly board with exceptions and to be honest I would rather not have to ask questions on it. As a matter of fact earlier today I asked on a non-php board a php question because I really like that board. The people are friendly and want to help others. They aren't as much concerned that someone asks questions in the proper way, but they try their best to help others. If I ask another question on this board, (and I probably will), you have absolutely no obligation to answer me just as anyone else doesn't. But to make a comment such as you did in your post is ridiculous. You sound like a person I'd rather not associate with. You probably don't even golf! But still I wish you well in anything you pursue. Just try to remember we are all human and not too many are perfect like you!
  16. Figured this out. I placed the if statement just below the while and it works well....
  17. Sorry about that. Here is the script with the sql..... $sql = "SELECT itemnum,title,close,quantity,bidquantity, " . " bidprice,buyitprice,buser,bidder,biditem " . " FROM Items LEFT OUTER JOIN Bids " . " ON Items.itemnum = Bids.biditem " . " WHERE buser != '' and close > '$time' and outbid = ' 0 ' ". #"GROUP BY buser " . #"HAVING bidder=$buser or buser=\'$busername\' ". " ORDER by buser ASC "; $result = mysqli_query($con,$sql); $num = mysqli_num_rows($result); echo $num; echo "<br>"; $i = 0; $prebidder = null; while($row = mysqli_fetch_array($result)) { $buser = $row['buser']; $itemno = $row['biditem']; $price = $row['bidprice']; $qty = $row['bidquantity']; $query = "INSERT INTO invoiceitems(invnumber,itemnum,price,quantity) VALUES('$ttinvno','$itemno','$price','$qty')";#,unix_timestamp())"; mysqli_query($con,$query); $prebidder = $buser; if ( $prebidder != $buser ) { $ttinvno= $ttinvno +1; } $prebidder = $buser; $i++; } ?>
  18. I am trying to loop through a filtered table. This is the code of the loop: $result = mysqli_query($con,$sql); $num = mysqli_num_rows($result); $row = mysqli_fetch_array($result); $i = 0; $prebidder = $row['buser']; mysqli_data_seek($result,0); while($row = mysqli_fetch_array($result)) { $buser = $row['buser']; $itemno = $row['biditem']; $price = $row['bidprice']; $qty = $row['bidquantity']; $query = "INSERT INTO invoiceitems(invnumber,itemnum,price,quantity) VALUES('$ttinvno','$itemno','$price','$qty')";#,unix_timestamp())"; mysqli_query($con,$query); if ($prebidder != $buser) { $ttinvno= $ttinvno +1; } $prebidder = $buser; $i++; } ?> The filtered data has 55 rows of which 28 are unique. I am trying to loop through so that the names ($buser) match the invoice number ($ttinvno). I have the rows indexed on buser descending. But the rows don't seem to want to match correctly. The invoice numbers go in sequence correctly but for instance the first two rows have the same name. But no matter what I have done in this format either the invoice number changes after the first row, or it changes after the third row. I want it to change after the second row. I have tried multiple ways including prematurely defining row and then using mysqli_data_seek($result,0); to reset the result before the loop. Obviously there is a flaw in my code. Can anyone help? Thanks very much in advance!
  19. OK so I took the 'die' out ad I am actually trying to work only with the Bids table. Outbid is a tiny integer (1) and out of curiosity I echoed $outbid = $row['outbid']; echo $outbid; the outbid and I get a zero. But if I put 'where outbid = 0', I get the error message: 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 '= '0'' at line 1 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\Apache24\htdocs\choo\testphp06.php on line 13 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\Apache24\htdocs\choo\testphp06.php on line 14 This happens whether I use quotes or not. I tried 1 for true. I tried false, 'false'. Nothing seems to work. I don't understand this at all. Further this seems to work in the second query with the two tables. At least it appears that way. Can anyone explain this? I did read something that this error can be fickle and it is really driving me nuts.....
  20. I just looked the field outbid and it is a smallint(1). So would that not be considered a number?
  21. Thanks very much for that critique. Very much appreciated. One comment. You mentioned that I should not put quotes around numbers. And I tried that in reference to this line: "WHERE buser != '' and close > $time and outbid = 0" So when I take the single quotes away from the 0 I get this error: Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\Apache24\htdocs\choo\testphp05.php on line 18 ...... Which is referencing this line: $result = mysqli_query($con,$sql) or die ( mysqli_error()); which is 18. The only way I have been successful in running the second query is by using the quotes. Is there an explanation for that? I'm going to study this and use it as a guide going forward. I really appreciate it!
  22. Sorry.. I had forgotten to paste my code in in my previous message...... <?php require('dbc.php'); $sql = mysqli_query($con,"SELECT * FROM invoice order by time desc"); $row = mysqli_fetch_array($sql); $invno = $row['invnumber']; $invno = $invno + 1; $ttinvno = $invno; $time = $row['time']; $sql = "SELECT itemnum, image1, title, close, quantity, bidquantity, ". "bidprice, buyitprice, seller, biditem, buser, bidder " . "FROM Items LEFT OUTER JOIN Bids " . "ON Items.itemnum = Bids.biditem " . "WHERE buser != '' and close > $time and outbid = '0'" . #"GROUP BY buser " . #"HAVING bidder=$buser or buser=\'$busername\' ". "ORDER by buser"; $result = mysqli_query($con,$sql) or die ( mysqli_error()); $i = 0; while($row = mysqli_fetch_array($result)) {; $seller = $row['seller']; $buyer = $row['bidder']; $price = $row['bidprice']; $sql = "INSERT INTO invoice(buyer,seller,subtotal) VALUES('$buyer','$seller','$price')";#,unix_timestamp())"; if(mysqli_query($con, $sql)){ #echo "Records inserted successfully."; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($con); } $invno= $invno +1; $i++; } $sql = "SELECT bidnum, biditem,bidder,bidquantity,bidprice,outbid,bidtime,invnumber,time " . "FROM Bids LEFT OUTER JOIN invoice " . "ON Bids.bidder = invoice.buyer " . "WHERE time = '' and outbid = '0'" . #"GROUP BY bidder " . #"HAVING bidder=$buser or buser=\'$busername\' " . "ORDER by invnumber ASC"; $result = mysqli_query($con,$sql) or die ( mysqli_error()); #$num = mysqli_num_rows($sql); #echo $num; while($row = mysqli_fetch_array($result)) {; $ttinvno = $row['invoice.invnumber']; $bidder = $row['bidder']; $itemno = $row['biditem']; $price = $row['bidprice']; $qty = $row['bidquantity']; $ttime = $row['time']; $sql = "INSERT INTO invoice_items(invnumber,itemnum,price,quantity) VALUES('$ttinvno','$itemno','$price','$qty')";#,unix_timestamp())"; if(mysqli_query($con, $sql)){ #echo "Records inserted successfully."; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($con); } #$ttinvno= $ttinvno +1; $i++; if ($bidder != $row['bidder']) { $ttinvno= $ttinvno +1; } } ?>
  23. Hi... I am still having problems. The first and second querys work well. the invoice table is inserted perfectly. (BTW I found out that invnumber in this table is actually auto increment!) The third query seems to end up empty every time as it inserts nothing into invoice_items. I've tried multiple combinations but I'm guessing the query is empty as it produces nothing into the invoice_items table. First is there a way of testing the query to see exactly how many rows it is producing? I tried it with #$num = mysqli_num_rows($sql); #echo $num; But that fails. How can I check to see if there is actually something produced by the query? Second is there anything obvious in the third query that may be preventing this from working? Thanks for any suggestions!
×
×
  • 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.