Jump to content

cutielou22

Members
  • Content Count

    71
  • Joined

  • Last visited

Community Reputation

1 Neutral

About cutielou22

  • Rank
    Regular Member
  • Birthday 07/22/1993

Contact Methods

  • Website URL
    http://mandyjosmith.com

Profile Information

  • Gender
    Female
  • Location
    USA
  • Interests
    Programming, music, games, tv.
  1. cutielou22

    Says

    It is working now. No errors. Kept the global $mysqli; And I got rid of the owner part - like you said no where that is stated. Thank you so much guys! Sorry if I was a pain the butt. I really wasn't trying to be. Thanks again.
  2. cutielou22

    Says

    I added global $mysqli; to the function directly under the "include_once "addon.inc.php";" Now no errors come up, but still nothing happens.
  3. cutielou22

    Says

    Okay. Gotcha. I added the below. error_reporting(E_ALL); // Report all errors Now 2 errors come up. So you guys are right. But what would cause the $mysqli error? Just a duplicate like said above? Even though I inserted my database connection directly in the function and renamed it and that didn't work either. Glad I am kind of getting somewhere though. Notice: Undefined variable: mysqli in /home3/solpetsc/public_html/funcs.inc.php on line 525Fatal error: Call to a member function prepare() on a non-object in /home3/solpetsc/public_html/funcs.inc.php on line 525
  4. cutielou22

    Says

    Taking out the part after the "AND " still creates the same "Fatal error: Call to a member function prepare() on a non-object in /home3/solpetsc/public_html/funcs.inc.php on line 522" error.
  5. cutielou22

    Says

    Here is the whole error: Fatal error: Call to a member function prepare() on a non-object in /home3/solpetsc/public_html/funcs.inc.php on line 522 It's this whole function: I did no edits so you can see my tests. I would post the page I am using the function on where it is not working. But it is not working on any of them. Also the error is showing up now without the below - or die code. I did used to get a error about the " AND `owner` = ?" part. Not sure how I was getting that error - cannot reproduce it now to get EXACTLY what it said, but it was talking about a nonobject and the " AND `owner` = ?" part. Switching the petid and owner order still caused the "AND . . . " problem. function gain_experience($gain_this_much, $grab_pet_id){ include_once "addon.inc.php"; //include "addon.inc.php"; //if(!$mysqli->query("UPDATE `userpets` SET `experience` = experience + $gain_this_much WHERE `owner` = '$userid' AND `petid` = '$grab_pet_id'") or die(mysqli_error($mysqli))){ $exper = $mysqli->prepare("UPDATE `userpets` SET `experience` = `experience` + ? WHERE `petid` = ? AND `owner` = ?"); //or die($mysqli->error . mysqli_error($mysqli)); $exper->bind_param('iss', $gain_this_much, $grab_pet_id, $userid); $exper->execute(); $exper->store_result(); //var_dump($mysqli); $exper->fetch(); $exper->close(); //die("Error description: " . mysqli_error($mysqli)); //} //////////////////// CHECK IF NEED LEVEL UPGRADE //////////////////// $stmt = $mysqli->prepare("SELECT level, experience FROM `userpets` WHERE owner = ? AND petid = ? LIMIT 1"); $stmt->bind_param('ss', $userid, $grab_pet_id); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($current_level, $new_experience); $stmt->fetch(); $stmt->close(); $current_levelm = $current_level - 1; $current_levelp = $current_level + 1; $check_experience = $current_level * 100; if (($new_experience >= $check_experience) && ($current_level > $current_levelm) && ($current_level < $current_levelp)) { $stmt3 = $mysqli->prepare("UPDATE `userpets` SET level=level+1 WHERE owner = ? AND petid = ?"); $stmt3->bind_param('ss', $userid, $grab_pet_id); $stmt3->execute(); $stmt3->store_result(); $stmt3->fetch(); $stmt3->close(); } //return 1; }
  6. cutielou22

    Says

    Even going in and adding the connection directly to the page instead of the include gives same error.
  7. cutielou22

    Says

    Yes I have. On another page but I have it in a php include. Not sure if this helps, but it is something I noticed and tested. If I use include() it gives no errors, but if I use require_one() or include_once() that's when it shows the error. (for the file with the connection)
  8. cutielou22

    Says

    $exper = $mysqli->prepare("UPDATE `userpets` SET `experience` = experience + ? WHERE `petid` = ? AND `owner` = ?") or die($mysqli->error . mysqli_error($mysqli)); $exper->bind_param('iss', $gain_this_much, $grab_pet_id, $userid); $exper->execute(); $exper->store_result(); //var_dump($mysqli); $exper->fetch(); $exper->close(); The code below gives me the error : "Fatal error: Call to a member function prepare() on a non-object . . . . " However there is no non-object. I use the EXACT SAME code on another page and no error. Updates correctly on other page also just not on this one page where it gives this error. Anyways to fix this? ALL ideas are welcome. I have tried query also. No luck. Does anyone know why this happens? I had this happen before , but I don't remember what I did to fix it. I know it was simple. Thanks in advance.
  9. cutielou22

    MYSQLI NOT UPDATING NO ERRORS

    I just fixed it! I knew it was going to be a tiny problem. Thank you guys for helping me. How I Fixed It: I been putting the $battleid in my url so I can see it. I just assumed as long as it was showing it would be the right one. Then just a little bit ago I did another test and noticed that the $battleid should be higher than that. So I have the correct one showing on another page - so I checked to see if it matched or if this may be the error I am looking for! It was the error I was looking for. The problem was I was grabbing the wrong $battleid (which did not need to be updated so it wasn't - makes sense right?!). Man, I feel stupid and so relieved at the same time. So ALWAYS do a double triple check for your SELECT mysql. x) Thanks guys for your time though. I really do appreciate it.
  10. cutielou22

    MYSQLI NOT UPDATING NO ERRORS

    haha I realize you did not use quotes "" but used the single quote. Using the single quotes for the strings I got a error, but making it into quotes with singles quotes made the error go away. (Can't remember exactly how I did it to show you - google helped me.) It was still not updating the database though. Just got rid of the error.
  11. cutielou22

    MYSQLI NOT UPDATING NO ERRORS

    @barand Tried that already. No errors. @requinix I thought I tried this once, but tried again and got a error. Then looked up the error and it ended up me adding quotes to remove the error. . . . . though database still not updating. Same results. I know this is an extremely odd problem.
  12. cutielou22

    MYSQLI NOT UPDATING NO ERRORS

    Yes, my variables are correct. The thing I really don't get is that the exact same snippet of code is working on another page, but not this page. What could cause that? I even bothered checking the permissions of the page.
  13. cutielou22

    MYSQLI NOT UPDATING NO ERRORS

    It seems none of the mysqli is updating on this ONE page I have. It works fine on all other pages (even using the same tables) - just not this one. It is super weird. Could it be a page problem? Is that a thing? I have tried many . . . many trial error options in more than 2 and 1/2 hours - absolutely none of them give any errors. This is how most of them look or similar. There is only 3 different tables that I update on this page and none of them update or give errors. I am at a lost. $stmt = $mysqli->prepare("UPDATE `solbattle` SET `pet_turn` = 'pet_one', `p2_turns`=p2_turns+1 WHERE (`player_one` = ? OR `player_two` = ?) AND `battle_status` = 'active' AND `winner` = '' AND `battleid` = ?"); $stmt->bind_param('sss', $userid, $userid, $battleid); $stmt->execute(); $stmt->store_result(); $stmt->close();
  14. cutielou22

    Javascript Pop Up Alert

    It also automatically chooses the last one no matter which one is picked from the list to delete. It also does not actually delete a selection if added. It goes right to the next one. (THIS HOWEVER DID WORK BEFORE) <<For when choosing "Yes".
  15. cutielou22

    Javascript Pop Up Alert

    I am working with the code from this: https://codepen.io/adventuresinmissions/pen/nrhHF I have made my own slight changes, but I am having a problem. I am getting data from a mysql table. If the page has more than one element (or row) from the table shown it will pop up the popup for each - if hitting "No" or "Cancel". I just want it to show one pop up and go away. Not go to the next pop up/row. Hope that makes sense. The Code I am Using on the Page: ECHO<<<END <script> jQuery(document).ready(function($){ //open popup $('.cd-popup-trigger$count').on('click', function(event){ event.preventDefault(); $('.cd-popup').addClass('is-visible'); }); //close popup $('.cd-popup').on('click', function(event){ if( $(event.currentTarget).is('.cd-popup-close') || $(event.currentTarget).is('.cd-popup') ) { event.preventDefault(); $(this).removeClass('is-visible'); } }); //close popup when clicking the esc keyboard button $(document).keyup(function(event){ if(event.which=='27'){ $('.cd-popup').removeClass('is-visible'); } }); }); </script> <style> .img-replace { /* replace text with an image */ display: inline-block; overflow: hidden; text-indent: 100%; color: transparent; white-space: nowrap; } .cd-popup { position: fixed; left: 0; top: 0; height: 100%; width: 100%; background-color: rgba(94, 110, 141, 0.9); opacity: 0; visibility: hidden; -webkit-transition: opacity 0.3s 0s, visibility 0s 0.3s; -moz-transition: opacity 0.3s 0s, visibility 0s 0.3s; transition: opacity 0.3s 0s, visibility 0s 0.3s; } .cd-popup.is-visible { opacity: 1; visibility: visible; -webkit-transition: opacity 0.3s 0s, visibility 0s 0s; -moz-transition: opacity 0.3s 0s, visibility 0s 0s; transition: opacity 0.3s 0s, visibility 0s 0s; } .cd-popup.show_button { opacity: 1; visibility: visible; -webkit-transition: opacity 0.3s 0s, visibility 0s 0s; -moz-transition: opacity 0.3s 0s, visibility 0s 0s; transition: opacity 0.3s 0s, visibility 0s 0s; display: block; height: 60px; line-height: 60px; text-transform: uppercase; color: #FFF; -webkit-transition: background-color 0.2s; -moz-transition: background-color 0.2s; transition: background-color 0.2s; } .cd-popup-container { position: relative; width: 90%; max-width: 400px; margin: 4em auto; background: #FFF; border-radius: .25em .25em .4em .4em; text-align: center; box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); -webkit-transform: translateY(-40px); -moz-transform: translateY(-40px); -ms-transform: translateY(-40px); -o-transform: translateY(-40px); transform: translateY(-40px); /* Force Hardware Acceleration in WebKit */ -webkit-backface-visibility: hidden; -webkit-transition-property: -webkit-transform; -moz-transition-property: -moz-transform; transition-property: transform; -webkit-transition-duration: 0.3s; -moz-transition-duration: 0.3s; transition-duration: 0.3s; } .cd-popup-container p { padding: 3em 1em; } .cd-popup-container .cd-buttons:after { content: ""; display: table; clear: both; } .cd-popup-container .cd-buttons li { float: left; width: 50%; list-style: none; } .cd-popup-container .cd-buttons a { display: block; height: 60px; line-height: 60px; text-transform: uppercase; color: #FFF; -webkit-transition: background-color 0.2s; -moz-transition: background-color 0.2s; transition: background-color 0.2s; } .cd-popup-container .cd-buttons li:first-child a { background: #fc7169; border-radius: 0 0 0 .25em; } .no-touch .cd-popup-container .cd-buttons li:first-child a:hover { background-color: #fc8982; } .cd-popup-container .cd-buttons li:last-child a { background: #b6bece; border-radius: 0 0 .25em 0; } .no-touch .cd-popup-container .cd-buttons li:last-child a:hover { background-color: #c5ccd8; } .cd-popup-container .cd-popup-close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; } .cd-popup-container .cd-popup-close::before, .cd-popup-container .cd-popup-close::after { content: ''; position: absolute; top: 12px; width: 14px; height: 3px; background-color: #8f9cb5; } .cd-popup-container .cd-popup-close::before { -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); transform: rotate(45deg); left: 8px; } .cd-popup-container .cd-popup-close::after { -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); -ms-transform: rotate(-45deg); -o-transform: rotate(-45deg); transform: rotate(-45deg); right: 8px; } .is-visible .cd-popup-container { -webkit-transform: translateY(0); -moz-transform: translateY(0); -ms-transform: translateY(0); -o-transform: translateY(0); transform: translateY(0); } @media only screen and (min-width: 1170px) { .cd-popup-container { margin: 8em auto; } } </style> END; $stmt = $mysqli->prepare("SELECT state_name FROM states WHERE state_code = ?"); $stmt->bind_param('s', $state_code); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($state_name); $stmt->fetch(); $stmt->close(); $stmt2 = $mysqli->prepare("SELECT toll, crime_rate, traffic, population, city, state_code, latitude, longitude, last_updated FROM states_cities WHERE `zip` = ?"); $stmt2->bind_param('i', $zip); $stmt2->execute(); $stmt2->store_result(); $stmt2->bind_result($toll, $crime_rate, $traffic, $population, $city, $state, $lat_to, $lon_to, $last_updated); $stmt2->fetch(); $stmt2->close(); echo "<h1>$city, <a href=\"state_details.php?state=$state_code\">$state_name</a></h1>"; if ($rank >= 10) { $stmt3 = $mysqli->prepare("SELECT latitude, longitude FROM states_cities WHERE zip = ?"); $stmt3->bind_param('i', $user_zip); $stmt3->execute(); $stmt3->store_result(); $stmt3->bind_result($lat_from, $lon_from); $stmt3->fetch(); $stmt3->close(); $travel_time = get_distance($lat_to, $lat_from, $lon_to, $lon_from); echo "Distance: $travel_time[distance] | Travel Time: $travel_time[time]"; } else { $travel_time = ""; } if($rank == 20) { if ((!empty($toll))) { //Add form to EDIT FORM city information } else { //Add form to ADD FORM city information to site } } if ($rank >= 18) { echo "<center><a href=\"attractions/index.php?state=$state_code\">Add Attraction</a> | <a href=\"stores/index.php?state=$state_code\">Add Store</a></center>"; } $stmt = $mysqli->prepare("SELECT name, price, free, parking_fee, discount, hours_daily, hours_weekend, address, city, zip, attract_id FROM states_attractions WHERE (city = ? OR zip = ?) AND `state` = ?"); $stmt->bind_param('sis', $city, $zip, $state_code); $stmt->execute(); $stmt->store_result(); $num_attracts = $stmt->num_rows; $stmt->bind_result($name, $price, $free, $parking_fee, $discount, $hours_daily, $hours_weekend, $address, $city, $zip, $attract_id); if ($num_attracts >= 1) { echo "<h2>Attractions</h2>"; //$count = 0; while ($stmt->fetch()) { //$count++; if ((!empty($parking_fee)) || ($parking_fee != "0.00")) { $total = $price + $parking_fee; $show_fee = " + $$parking_fee ($$total)"; } else { $show_fee = ""; } if ($rank >= 18) { $show_admin = " | <a href=\"attractions/edit.php?id=$attract_id\">EDIT</a> | <a href=\"\" class=\"cd-popup-trigger\"><font color=\"red\">DELETE</font></a>"; echo " <div class=\"cd-popup\" role=\"alert\"> <div class=\"cd-popup-container\"> <p>Are you sure you want to delete this attraction?</p> <ul class=\"cd-buttons\"> <li><a href=\"attractions/delete.php?id=$attract_id\">Yes</a></li> <li><a href=\"#0\" class=\"cd-popup-close\">No</a></li> </ul> <a href=\"#0\" class=\"cd-popup-close img-replace\">Close</a> </div> <!-- cd-popup-container --> </div> <!-- cd-popup -->"; } else { $show_admin = ""; } if ($rank >= 10) { $show_user = " | <a href=\"addtotrip.php?id=$attract_id\">ADD TO TRIP</a>"; } else { $show_user = ""; } if (!empty($discount)) {$show_discount = " Discount: $discount";} else {$show_discount = "";} if ($free == "yes") {$final_price = "FREE";} else {$final_price = "$$price";} $url_address = urlencode($address); $url_city = urlencode($city); echo "<div class=\"link_desc\">$name<sub>$final_price$show_fee $show_discount | Daily Hours: $hours_daily | Weekend Hours: $hours_weekend | <a href=\"http://maps.google.com/maps?q=$url_address,+$url_city,+$zip\" target=\"_blank\">$address, $city, $zip</a>$show_user$show_admin</sub></div>"; } } $stmt->close();
×

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.