Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Because on the first iteration of the while loop $TotalCashoutsMade is not defined. To prevent the notice you should initialise this variable before the while loop $TotalCashoutsMade = 0; // init $TotalCashoutsMade to zero if($TotalCashoutsNumRow > 0){ while($TotalCashoutsRow = $TotalCashouts->fetch(PDO::FETCH_ASSOC)){ $TotalCashoutsMade += $TotalCashoutsRow['amount']; // add $TotalCashoutsRow['amount'] to $TotalCashoutsMade } } No that $TotalCashoutsMade is defined before the while loop, the else statement is not needed.
  2. Are you sure you have uploaded all files correctly? Are there any JavaScript errors reported in your browsers console (F12 > console tab)?
  3. That would be the expected behaviour. When you use return it only returns the variables value, not the variable itself. I recommend you to read up on the following User-defined Functions Function Arguments Returning Values and Variable Scope - Ignoring anything to do with globals
  4. Your query is most likely producing an error. What is the output of echo mysql_error(); After running your query?
  5. The solution you are after is AJAX. I have moved this to the Ajax Forum for you.
  6. Globals should not be used at all. You should be passing $conn as a function argument So your getCon function should be coded like function connectDB($host, $user, $pass, $db) { $conn = new mysqli($host, $user, $pass, $db); if($conn->connect_errno > 0) { die('Unable to connect to database [' . $conn->connect_error . ']'); } return $conn; // return the mysqli object } Then when you want to connect to the database, you pass this function the db credentials //connect to mysql $host = 'localhost'; $dbUsername = 'username'; $dbPassword = 'password'; $db = 'db'; $port = 3306; $conn = connectDB($host, $dbUsername, $dbPassword, $db); // connect to db, capture the returned mysqli instance/object And the capture the returned mysqli instance/object on calling the function Any function whereby you need to interact with the database, you should pass $conn as a function argument and not as global, eg your insertInfoToDB function should be coded like // define the mysqli object as function argument function insertInfoToDB($conn, $year, $month, $day, $userUID) { $sql = "call insertInfo ('$year', '$month', '$day', '$userUID');"; mysqli_query($conn, $sql); mysqli_close($conn); } Then when calling the function it'll be $conn = connectDB(...); // when calling function, pass it the mysqli object insertInfoToDB($conn, $year, $month, $day, $userID);
  7. For the spacing apply a margin to the table in your css table { margin: 10px; /* Applies 10px space around each table */ } What code did you try? Post your code here.
  8. If you are getting that result then & symbols have most likely been html encoded to & In which case you'll need use str_replace with & instead $text = str_replace('&', '', $text); Or use html_entity_decode prior to str_replace and then apply htmlentities again afterwards
  9. PHP's built in mail() function does not support Gmail. However you can use a third party PHP script called PHPMailer
  10. That code makes not sense at all. Why have you changed from phyco's original code posted here?
  11. Yes you could do. Or you could separate your code into multiple php files and then just include them when needed
  12. Welcome! You can now sign of your own darn reports
  13. Use isset on that var if (isset($_POST['submit']))
  14. Yes, to see what the error is use mysql_error()
  15. You are passing the users user_id via a query string parameter called id not id_user <td bgcolor="#FFFFFF"><a href="delete2.php?id=<? echo $rows['id_user']; ?>">delete</a></td> You should be using $_GET['id'] in delete2.php when retrieving the users id
  16. This if (isset($_SESSION['seat'])) { if ($_SESSION['seat'] == "") { $_SESSION['seat']=$_POST['seat']; } else { $_SESSION['seat'] .=",".$_SESSION['seat']; } } else { $_SESSION['seat']=$_POST['seat']; } should be if (isset($_SESSION['seat']) && !empty($_SESSION['seat'])) { $_SESSION['seat'] = array(); // deiine $_SESSION['seat'] as an array } $_SESSION['seat'][] = $_POST['seat']; // add selected seat to array The foreach loop on newpage.php will then be foreach($_SESSION['seat'] as $stt) { echo $stt."<br>"; }
  17. Can you explain further what you mean by this? Is this code not in index.php?
  18. use ($test) can only be used with anonymous functions. If you're not going to use anonymous functions then you'll need to use .josh's second code example, which was
  19. You need to echo $total in your hidden form field <input type="hidden" name="total" value="<?php echo $total; ?>" /> Then you need to set $first to $_POST['total'] when the form has been submitted if(isset($_POST['Calculate'])) { $first = $_POST['total']; $second = $_POST['second']; ...
  20. I've not used twitter API, but your code appears to be using their v1 API. Rading thier docs they have retired this API, instead you need to use their newer v1.1 API
  21. Most likely PHP has encountered an error in your code. Add the following to the top of your script. Any errors reported? ini_set('display_errors',1); error_reporting(E_ALL);
  22. You need to use preg_replace_callback, If you're using PHP5.3 or latter you'll can use an anonymous function as the callback $ret = preg_replace_callback('#\[%(.+)%\]#iUs', function($m) { return strtoupper($m[1]); // upper case the captured word } , $ret); otherwise the code will be function makeUppercase($m) { return strtoupper($m[1]); } $ret = preg_replace_callback('#\[%(.+)%\]#iUs', 'makeUppercase', $ret);
  23. if you are mysqli then at least us prepare statements So change $post_count = count($_POST['slno']); $sl_no = array(); $album_name = array(); $paper_used = array(); $finishing = array(); $price = array(); $vat = array(); $total_amt = array(); $sl_no = $_POST['slno']; $album_name = $_POST['album_name']; $paper_used = $_POST['paper_used']; $finishing = $_POST['finishing']; $price = $_POST['price']; $vat = $_POST['vat']; $total_amt = $_POST['total_amt']; for ($i = 0; $i <= $post_count; $i++) { $sql[] = "INSERT INTO customer_album_price(customer_id, customer_name, customer_user_name, sl_no, album_name, paper, finish, price, vat, total_amt, date, time) VALUES ($customer_id','$customer_name','$customer_user_name','".$sl_no[$i]."','".$album_name[$i]."','".$paper_used[$i]."','".$finishing[$i]."','".$price[$i]."','".$vat[$i]."','".$total_amt[$i]."','$date','$time')"; } foreach ($sql as $query) { mysqli_query($con, $query); } to // prepare the query $stmt = mysqli_prepare($con, 'INSERT INTO customer_album_price (customer_id, customer_name, customer_user_name, sl_no, album_name, paper, finish, price, vat, total_amt, date, time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); // bind the variables to be used in the query mysqli_bind_param($stmt, 'ississsiiiss', $customer_id, $customer_name, $customer_user_name, $sl_no, $album_name, $paper_used, $finishing, $price, $vat, $total_amt, $date, $time); foreach($_POST['slno'] as $index => $sl_no) { $album_name = $_POST['album_name'][$index]; $paper_used = $_POST['paper_used'][$index]; $finishing = $_POST['finishing'][$index]; $price = $_POST['price'][$index]; $vat = $_POST['vat'][$index]; $total_amt = $_POST['total_amt'][$index]; mysqli_stmt_execute($stmt); // execute prepared statement } mysqli_stmt_close($stmt);
  24. Yes this is possible. Can you tell us what these images are? And what is pink block, yellow block etc? Have you tried any code
  25. You need to make sure you are outputting your urls like <a href="http://localhost/demo/post/my post title here">my post title here</a> not as <a href="http://localhost/demo/post.php?title=my post title here">my post title here</a>
×
×
  • 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.