PHP - How To Handle Json Respond From Api Endpoint (uncaught Typeerror: )
My problem is how to handle this json respond using document.getElementById or any other methods. I needed to output the value of 'P'. And also work with php echo on the output [ { "a": 26129, "p": "0.01633102", "q": "4.70443515", "f": 27781, "l": 27781, "T": 1498793709153, "m": true, "M": true } ] Bellow is the code I'm working with. it gives Uncaught TypeError: Cannot read property 'p' of undefined <!DOCTYPE html> <html> <body> <h2> Price</h2> <p id="demo"></p> <script> var burl = "https://api3.binance.com"; /////////// baseurl///////// var query = '/api/v3/aggTrades'; query += '?symbol=BTCUSDT'; var url = burl + query; var ourRequest = new XMLHttpRequest(); ourRequest.open('GET',url,true); ourRequest.onload = function(){ console.log(ourRequest.responseText); } var obj = ourRequest.send(); document.getElementById("demo").innerHTML = obj.p; </script> </body> </html> Please help me and thanks in advance Similar TutorialsCan anyone help by shedding some light with a little problem I encounter using JSON endpoint requests. I'm not very good with PHP. When the endpoint is called and finds no data, I want to replace it with a local image source. In this case, I am calling brewery->logo_url. Most entries have endpoints, but some don't. When an image link is found at the endpoint, it throws off my layout. You can see the ones that look off. They align to the left. I want to replace with a logo default image each time this happens, with hopes to set the layout adjust back to normal. Here's my working document http://graintoglass....p-menu-test.php and here's the JSON. http://mcallen.taphu...mat=jsonv2short Code Effort <?php $url = 'http://mcallen.taphunter.com/widgets/locationWidget?location=Grain-To-Glass&format=jsonv2short&servingtype=bottlecan'; $curl_session = curl_init($url); curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, 4); curl_setopt($curl_session, CURLOPT_TIMEOUT, 10); $data = curl_exec($curl_session); curl_close($curl_session); $beer_list = json_decode($data); echo '<p class="last-updated">Last Updated: ' . date("m/d/Y") . '</p>'; echo '<h1 class="page-title">Bottle List</h1>'; echo '<p class="page-intro">Not only do we serve a hefty list of brews on tap, we also offer an exclusive list of beers in bottle. Our bottle list is constantly changing so the occasional return visits to browse this list is the best way to stay up to date. Take a look!</p>'; foreach ($beer_list as $beer) { echo '<article class="beer-entry"> <div class="beer-image"><img src="'.$beer->brewery->logo_url.'" /></div> <div class="beer-info"> <p class="brewery-name">'.$beer->brewery->name.' — '.$beer->brewery->origin.'</p> <h2 class="beer-name">'.$beer->beer->name.'</h2> <p class="beer-style">Beer Style: '.$beer->beer->style.'</p> <p class="beer-description">'.$beer->descriptions->short_description.'</p> <p class="beer-abv">ABV: '.$beer->beer->abv.' / IBU: '.$beer->beer->ibu.'</p> <p class="beer-ibu"></p> </div> <div class="clearfix"></div> </article> '; } echo '<p class="page-bottom">If you would like to see more of our food and beer options, <a href="https://www.graintoglass.com" target="_blank">visit our website</a>.</p>'; ?> Edited by meylo, 10 December 2014 - 06:35 PM. I'm getting this error for a blog script that is on my site :- PHP Fatal error: Uncaught TypeError: Unsupported operand types: string - int
The line in questions is this :- $prev = $page - 1; If I comment out this block of code the blog appears (with other errors, but I'll move on to those if I can fix this first!).
/* Setup page vars for display. */
Any idea's on what's needed to fix this script? I've contacted the original author but they haven't got back to me, I guess PHP8 maybe a little too new for them. Thanks for any help....
<!DOCTYPE html>
{ I have a table with a list of users and an edit button and delete button. When the edit button is pressed on a site it passes the user_id as p_id to the page that catches it and displays the data. The problem is when I click on the "update user" button, I get the following error:
Warning: Undefined variable $the_user_id in C:\xampp\htdocs\3-19-21(2) - SafetySite\admin\edit_user.php on line 10 The weird thing is I had another update user page with a table I created that ran the query to update the table in the database just fine. But as I created it, it didn't look all that great so I recreated the page and used a bootstrap table because of the much cleaner look. Both pages have the exact same PHP code, the only difference is the bootstrap table I added in. So I'm really at a loss with this. Other than the table and PHP code, there is a script at the bottom of the page for the table itself to allow for searching within the table, i'll include that as well. The PHP code is as follows:
<?php //THE "p_id" IS BROUGHT OVER FROM THE EDIT BUTTON ON VIEW_ALL_USERS if (isset($_GET['p_id'])) { $the_user_id = $_GET['p_id']; } // QUERY TO PULL THE SITE INFORMATION FROM THE p_id THAT WAS PULLED OVER $query = "SELECT * FROM users WHERE user_id = $the_user_id "; $select_user = mysqli_query($connection,$query); //SET VALUES FROM ARRAY TO VARIABLES while($row = mysqli_fetch_assoc($select_user)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_email = $row['user_email']; $user_phone = $row['user_phone']; //$user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id']; } THE UPDATE QUERY CODE....................................................................................................................
<?php if(isset($_POST['update_user'])) { $user_id = $_POST['user_id']; $user_firstname = $_POST['user_firstname']; $user_lastname = $_POST['user_lastname']; $username = $_POST['username']; $user_email = $_POST['user_email']; $user_phone = $_POST['user_phone']; //$user_image = $_POST['user_image']; $user_title_id = $_POST['user_title_id']; $user_role_id = $_POST['user_role_id'];
$query = "UPDATE users SET "; $query .= "user_id = '{$user_id}', "; $query .= "user_firstname = '{$user_firstname}', "; $query .= "user_lastname = '{$user_lastname}', "; $query .= "username = '{$username}', "; $query .= "user_email = '{$user_email}', "; $query .= "user_phone = '{$user_phone}', "; //$query .= "user_image = '{$user_image}', "; $query .= "user_title_id = '{$user_title_id}', "; $query .= "user_role_id = '{$user_role_id}' "; $query .= "WHERE user_id = '{$the_user_id}' "; $update_user = mysqli_query($connection,$query); if(! $update_user) { die("QUERY FAILED" . mysqli_error($connection)); } } ?> THE "UPDATE USER" BUTTON THE USER CLICKS ON TO UPDATE....................................................................................................................
<div class="col-1"> <button class="btn btn-primary" type="submit" name="update_user">Update User</button> </div>
Any Help is Greatly Appreciated! Edited March 23 by Zserene
In PHP Version 8.0 shows error as : In previous versions of PHP it does not show any error. Please resolve the issue. Hi Friends , We have the JSON Data coming in this format, $invoice_data = { "CONTACT_ID": "1", "INV_SERIAL_NO": "100", "NAME": "baby", "INV_DATE": "2018-06-27", "DUE_DATE": "2018-06-27", "CURRENCY": "KD", "SUBTOTAL": "143", "TAX_TOTAL": "13", "shipment_data": [ { "SHIP_SERIAL_NO": "44", "MASTER_NO": "55", "HOUSE_NO": "88", "cost_revenue_items": [ { "CHARGE_REF": "tt", "CURRENCY": "INR", "QUANTITY": "2", "SELLING_RATE": "45", "EXCHANGE_RATE": "987" },{ "CHARGE_REF": "ii", "CURRENCY": "INR", "QUANTITY": "2", "SELLING_RATE": "45", "EXCHANGE_RATE": "456" },{ "CHARGE_REF": "op", "CURRENCY": "INR", "QUANTITY": "2", "SELLING_RATE": "45", "EXCHANGE_RATE": "456" } ] } ] } How to write DELETE End-point for child data-set "cost_revenue_items". What I mean to say is how to handle the request to delete one of item from "cost_revenue_items".
When "cost_revenue_items" will be deleted ,master "invoice_data" will be updated. This update , we can handle by PUT, but how do we know under that PUT, we have to Will JSON request to delete "cost_revenue_items" looks like this ,if it want to delete last record : $invoice_data = { "CONTACT_ID": "1", "INV_SERIAL_NO": "100", "NAME": "baby", "INV_DATE": "2018-06-27", "DUE_DATE": "2018-06-27", "CURRENCY": "KD", "SUBTOTAL": "143", "TAX_TOTAL": "13", "shipment_data": [ { "SHIP_SERIAL_NO": "44", "MASTER_NO": "55", "HOUSE_NO": "88", "cost_revenue_items": [ { "CHARGE_REF": "tt", "CURRENCY": "INR", "QUANTITY": "2", "SELLING_RATE": "45", "EXCHANGE_RATE": "987" },{ "CHARGE_REF": "ii", "CURRENCY": "INR", "QUANTITY": "2", "SELLING_RATE": "45", "EXCHANGE_RATE": "456" } ] } ] } Kindly help me to know , how JSON request will look like ?
Thanks a lot Hello, is this ok to do? or should I add in some type of fail safe in case for some reason the server is down etc? If so, how? Code: [Select] public function check_update() { $query = $this->db->where('setting_name', 'version')->get('settings')->row(); $latest = file_get_contents('http://www.mydomain.com/version.txt') ) if ( version_compare($query->value, $latest, '<') ) return true; else return false; } Hello,
I am hoping to get some help with this. I want to apologize in advance as I am not a developer more of a systems admin guy. Okay guys, here is the deal. My boss has a website, which uses from my understanding Wordpress for design, but also uses PHP. Since, I am not too familiar with the general uses of PHP, I cannot explain why they are doing it that way. The website also uses MYSQL, which I would imagine works with PHP to gather data from some back end server.
The website has five tabs on the top right corner
about services resources contact us login
When you hover over these five tabs they expand and show more menus. The tab with the issue is the services tab. When you hover over it, it works as anticipated; it expands and shows our services. Upon getting on there, there are a bunch of services, which you can click on. When you first click, it works as anticipated. However, if you try to click on another service within that category, it simply does not load the page. Now if you decide to go into a different service it works, but once you try to click on another services within x category it just does not work.
I would really appreciate everyone's help on this. It would be nice to get this resolve.
I can provide you guys with the website and php scripts and codes if need be.
This is the website
http://beta.morrowco.com/
Thanks,
Jeff M
Does somebody know, where the issue is when the external hard drives respond very slow to a point where one can not copy over a small sized file?
I have this issue with different types of external hard drives.
I am using Windows 8.
Edited by glassfish, 01 December 2014 - 09:36 AM. I received this error message. Any idea what is causing this? Uncaught CurlException: 77: error setting certificate verify locations: CAfile: /www-urs/jb1/jason.com/fun.jason.com/assets/lib/fb_ca_chain_bundle.crt CApath: /etc/ssl/certs Folks,
I got this pagination without PREP STMT working ABSOLUTELY FINE:
<?php //Required PHP Files. include 'header_account.php'; //Required on all webpages of the Account. ?> <?php if (!$conn) { $error = mysqli_connect_error(); $errno = mysqli_connect_errno(); print "$errno: $error\n"; exit(); } //Grab Username of who's Browsing History needs to be searched. if (isset($_GET['followee_username']) && !empty($_GET['followee_username'])) { $followee_username = $_GET['followee_username']; if($followee_username != "followee_all" OR $followee_username != "Followee_All") { $query = "SELECT * FROM following_histories WHERE followee_username = \"$followee_username\""; $query_type = "followee_username"; $followed_word = "$followee_username"; $followee_username = "$followee_username"; echo "$followee_username"; } else { $query = "SELECT * FROM following_histories"; $query_type = "followee_all"; $followed_word = "followee_all"; echo "all"; } } if (isset($_GET['followee_id']) && !empty($_GET['followee_id'])) { $followee_id = $_GET['followee_id']; $query = "SELECT * FROM following_histories WHERE id = \"$followee_id\""; $query_type = "followee_id"; $followed_word = "$followee_id"; echo "$followee_id"; } if (isset($_GET['followee_date_and_time']) && !empty($_GET['followee_date_and_time'])) { $followee_date_and_time = $_GET['followee_date_and_time']; $query = "SELECT * FROM following_histories WHERE date_and_time = \"$followee_date_and_time\""; $query_type = "followee_date_and_time"; $followed_word = "$followee_date_and_time"; } if (isset($_GET['followee_followed_page_converted']) && !empty($_GET['followee_followed_page_converted'])) { $followee_followed_page_converted = $_GET['followee_followed_page_converted']; $query = "SELECT * FROM following_histories WHERE followed_page_converted = \"$followee_followed_page_converted\""; $query_type = "followee_followed_page_converted"; $followed_word = "$followee_followed_page_converted"; } if (isset($_GET['followee_referral_page_converted']) && !empty($_GET['followee_referral_page_converted'])) { $followee_referral_page_converted = $_GET['followee_referral_page_converted']; $query = "SELECT * FROM following_histories WHERE referral_page_converted = \"$followee_referral_page_converted\""; $query_type = "followee_referral_page_converted"; $followed_word = "$followee_referral_page_converted"; } if (isset($_GET['followee_gender']) && !empty($_GET['followee_gender'])) { $followee_gender = $_GET['followee_gender']; $query = "SELECT * FROM following_histories WHERE gender = \"$followee_gender\""; $query_type = "followee_gender"; $followed_word = "$followee_gender"; } if (isset($_GET['followee_age_range']) && !empty($_GET['followee_age_range'])) { $followee_age_range = $_GET['followee_age_range']; $query = "SELECT * FROM following_histories WHERE age_range = \"$followee_age_range\""; $query_type = "followee_age_range"; $followed_word = "$followee_age_range"; } if (isset($_GET['followee_date_of_birth']) && !empty($_GET['followee_date_of_birth'])) { $followee_date_of_birth = $_GET['followee_date_of_birth']; $query = "SELECT * FROM following_histories WHERE date_of_birth = \"$followee_date_of_birth\""; $query_type = "followee_date_of_birth"; $followed_word = "$followee_date_of_birth"; } if (isset($_GET['followee_skin_complexion']) && !empty($_GET['followee_skin_complexion'])) { $followee_skin_complexion = $_GET['followee_skin_complexion']; $query = "SELECT * FROM following_histories WHERE skin_complexion = \"$followee_skin_complexion\""; $query_type = "followee_skin_complexion"; $followed_word = "$followee_skin_complexion"; } if (isset($_GET['followee_height']) && !empty($_GET['followee_height'])) { $followee_height = $_GET['followee_height']; $query = "SELECT * FROM following_histories WHERE height = \"$followee_height\""; $query_type = "followee_height"; $followed_word = "$followee_height"; } if (isset($_GET['followee_weight']) && !empty($_GET['followee_weight'])) { $followee_weight = $_GET['followee_weight']; $query = "SELECT * FROM following_histories WHERE weight = \"$followee_weight\""; $query_type = "followee_weight"; $followed_word = "$followee_weight"; } if (isset($_GET['followee_sexual_orientation']) && !empty($_GET['followee_sexual_orientation'])) { $followee_sexual_orientation = $_GET['followee_sexual_orientation']; $query = "SELECT * FROM following_histories WHERE sexual_orientation = \"$followee_sexual_orientation\""; $query_type = "followee_sexual_orientation"; $followed_word = "$followee_sexual_orientation"; } if (isset($_GET['followee_religion']) && !empty($_GET['followee_religion'])) { $followee_religion = $_GET['followee_religion']; $query = "SELECT * FROM following_histories WHERE religion = \"$followee_religion\""; $query_type = "followee_religion"; $followed_word = "$followee_religion"; } if (isset($_GET['followee_education']) && !empty($_GET['followee_education'])) { $followee_education = $_GET['followee_education']; $query = "SELECT * FROM following_histories WHERE education = \"$followee_education\""; $query_type = "followee_education"; $followed_word = "$followee_education"; } if (isset($_GET['followee_profession']) && !empty($_GET['followee_profession'])) { $followee_profession = $_GET['followee_profession']; $query = "SELECT * FROM following_histories WHERE profession = \"$followee_profession\""; $query_type = "followee_profession"; $followed_word = "$followee_profession"; } if (isset($_GET['followee_marital_status']) && !empty($_GET['followee_marital_status'])) { $followee_marital_status = $_GET['followee_marital_status']; $query = "SELECT * FROM following_histories WHERE marital_status = \"$followee_marital_status\""; $query_type = "followee_marital_status"; $followed_word = "$followee_marital_status"; } if (isset($_GET['followee_working_status']) && !empty($_GET['followee_working_status'])) { $followee_working_status = $_GET['followee_working_status']; $query = "SELECT * FROM following_histories WHERE working_status = \"$followee_working_status\""; $query_type = "followee_working_status"; $followed_word = "$followee_working_status"; } if (isset($_GET['followee_country_of_birth']) && !empty($_GET['followee_country_of_birth'])) { $followee_country_of_birth = $_GET['followee_country_of_birth']; $query = "SELECT * FROM following_histories WHERE country_of_birth = \"$followee_country_of_birth\""; $query_type = "followee_country_of_birth"; $followed_word = "$followee_country_of_birth"; } if (isset($_GET['followee_home_town']) && !empty($_GET['followee_home_town'])) { $followee_home_town = $_GET['followee_home_town']; $query = "SELECT * FROM following_histories WHERE home_town = \"$followee_home_town\""; $query_type = "followee_home_town"; $followed_word = "$followee_home_town"; } if (isset($_GET['followee_home_neighbourhood']) && !empty($_GET['followee_home_neighbourhood'])) { $followee_home_neighbourhood = $_GET['followee_home_neighbourhood']; $query = "SELECT * FROM following_histories WHERE home_neighbourhood = \"$followee_home_neighbourhood\""; $query_type = "followee_home_neighbourhood"; $followed_word = "$followee_home_neighbourhood"; } if (isset($_GET['followee_home_borough']) && !empty($_GET['followee_home_borough'])) { $followee_home_borough = $_GET['followee_home_borough']; $query = "SELECT * FROM following_histories WHERE home_borough = \"$followee_home_borough\""; $query_type = "followee_home_borough"; $followed_word = "$followee_home_borough"; } if (isset($_GET['followee_home_city']) && !empty($_GET['followee_home_city'])) { $followee_home_city = $_GET['followee_home_city']; $query = "SELECT * FROM following_histories WHERE home_city = \"$followee_home_city\""; $query_type = "followee_home_city"; $followed_word = "$followee_home_city"; } if (isset($_GET['followee_home_county']) && !empty($_GET['followee_home_county'])) { $followee_home_county = $_GET['followee_home_county']; $query = "SELECT * FROM following_histories WHERE home_county = \"$followee_home_county\""; $query_type = "followee_home_county"; $followed_word = "$followee_home_county"; } if (isset($_GET['followee_home_district']) && !empty($_GET['followee_home_district'])) { $followee_home_district = $_GET['followee_home_district']; $query = "SELECT * FROM following_histories WHERE home_district = \"$followee_home_district\""; $query_type = "followee_home_district"; $followed_word = "$followee_home_district"; } if (isset($_GET['followee_home_region']) && !empty($_GET['followee_home_region'])) { $followee_home_region = $_GET['followee_home_region']; $query = "SELECT * FROM following_histories WHERE home_region = \"$followee_home_region\""; $query_type = "followee_home_region"; $followed_word = "$followee_home_region"; } if (isset($_GET['followee_home_state']) && !empty($_GET['followee_home_state'])) { $followee_home_state = $_GET['followee_home_state']; $query = "SELECT * FROM following_histories WHERE home_state = \"$followee_home_state\""; $query_type = "followee_home_state"; $followed_word = "$followee_home_state"; } if (isset($_GET['followee_home_country']) && !empty($_GET['followee_home_country'])) { $followee_home_country = $_GET['followee_home_country']; $query = "SELECT * FROM following_histories WHERE home_country = \"$followee_home_country\""; $query_type = "followee_home_country"; $followed_word = "$followee_home_country"; } $referral_page_http = $_SERVER['HTTP_REFERRER']; $referral_page = "$referral_page_http"; $referral_page_original = "$referral_page"; $query_string = $_SERVER['QUERY_STRING']; $current_page_http = $_SERVER['PHP_SELF']; $current_page = "$current_page_http"; $followed_page_original = "$current_page"; $visiting_pages_count = "1"; if($visiting_pages_count == "") { $visiting_pages_count = "1"; } else { $visiting_pages_count++; } if($visiting_pages_count == "1") { $current_page_converted = "$settings_user_first_quick_link.$current_page"; $referral_page_converted = "$settings_user_first_quick_link.$referral_page"; } elseif($visiting_pages_count == "2") { $current_page_converted = "$settings_admin_second_quick_link.$current_page"; $referral_page_converted = "$settings_admin_second_quick_link.$referral_page"; } elseif($visiting_pages_count == "3") { $current_page_converted = "$settings_user_third_quick_link.$current_page"; $referral_page_converted = "$settings_user_third_quick_link.$referral_page"; } elseif($visiting_pages_count == "4") { $current_page_converted = "$settings_admin_fourth_quick_link.$current_page"; $referral_page_converted = "$settings_admin_fourth_quick_link.$referral_page"; } elseif($visiting_pages_count == "5") { $current_page_converted = "$settings_user_fifth_quick_link.$current_page"; $referral_page_converted = "$settings_user_fifth_quick_link.$referral_page"; } if($visiting_pages_count == "6") { $current_page_converted = "$settings_admin_first_quick_link.$current_page"; $referral_page_converted = "$settings_admin_first_quick_link.$referral_page"; } elseif($visiting_pages_count == "7") { $current_page_converted = "$settings_user_second_quick_link.$current_page"; $referral_page_converted = "$settings_user_second_quick_link.$referral_page"; } elseif($visiting_pages_count == "8") { $current_page_converted = "$settings_admin_third_quick_link.$current_page"; $referral_page_converted = "$settings_admin_third_quick_link.$referral_page"; } elseif($visiting_pages_count == "9") { $current_page_converted = "$settings_user_fourth_quick_link.$current_page"; $referral_page_converted = "$settings_user_fourth_quick_link.$referral_page"; } elseif($visiting_pages_count == "10") { $current_page_converted = "$settings_admin_fifth_quick_link.$current_page"; $referral_page_converted = "$settings_admin_fifth_quick_link.$referral_page"; } else { $visiting_pages_count = "1"; $current_page_converted = "$settings_user_first_quick_link.$current_page"; $referral_page_converted = "$settings_user_first_quick_link.$referral_page"; } $followed_page_converted = "$current_page_converted"; $follower_username = $user; $follower_browser = $_SERVER['HTTP_USER_AGENT']; //Insert the User's Click Logs into Mysql Database using Php's Sql Injection Prevention Method "Prepared Statements". $stmt = mysqli_prepare($conn,"INSERT INTO following_histories(query_type,followed_word,query_string,followed_page_original,followed_page_converted,referral_page_original,referral_page_converted,followee_username,follower_username,gender,age_range,date_of_birth,skin_complexion,height,weight,sexual_orientation,religion,education,profession,marital_status,working_status,home_town,home_neighbourhood,home_borough,home_council,home_city,home_county,home_district,home_region,home_state,home_country) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); mysqli_stmt_bind_param($stmt,'ssssssssssiisssssssssssssssssss',$query_type,$followed_word,$query_string,$followed_page_original,$followed_page_converted,$referral_page_original,$referral_page_converted,$followee_username,$follower_username,$gender,$age_range,$date_of_birth,$skin_complexion,$height,$weight,$sexual_orientation,$religion,$education,$profession,$marital_status,$working_status,$home_town,$home_neighbourhood,$home_borough,$home_council,$home_city,$home_county,$home_district,$home_region,$home_state,$home_country); mysqli_stmt_execute($stmt); //Check if User's Click Logs have been successfully submitted or not. if (!$stmt) { echo "Sorry! Our system is currently experiencing a problem logging your following! We will continuously try logging your clicks!"; exit(); } else { mysqli_stmt_fetch($stmt); mysqli_stmt_close($stmt); } $query_type_label = str_replace("_"," ","$query_type"); //Removing underscores so they don't show-up on the html. $query_type_label = ucwords("$query_type_label"); //Upper Casing the first characters. ?> <!DOCTYPE html> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv=" content-type"> <title><?php echo "Browsing History in $server_time Time.";?></title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <br> <p align="center"><span style="font-weight:bold;"><?php echo "Search Result for:<br> $query_type_label = \"${$query_type}\""; ?></span></p> <br> <br> <?php $result = mysqli_query($conn,$query); $rows_num = mysqli_num_rows($result); //Total Number of Pages records are spread-over. $page_count = 100; $page_size = ceil($rows_num / $page_count); //Get the Page Number. Default is 1 (First Page). $page_number = $_GET["page_number"]; if ($page_number == "") $page_number = 1; $offset = ($page_number -1) * $page_size; $query .= " limit {$offset},{$page_size}"; $result = mysqli_query($conn,$query); ?> <table width="1500" border="0" cellpadding="5" cellspacing="2" bgcolor="#666666"> <?php if($rows_num) { printf("<b> %d Result Found ...</b>\n",$rows_num); ?><br> <br> <tr name="headings"> <td bgcolor="#FFFFFF" name="column-heading_submission-number">Submission Number</td> <td bgcolor="#FFFFFF" name="column-heading_logging-server-date-and-time">Date & Time in <?php echo "$server_time";?></td> <td bgcolor="#FFFFFF" name="column-heading_browsed-page-converted">Browsed Page Converted (Visit Page) </td> <td bgcolor="#FFFFFF" name="column-heading_browsed-page-converted">Browsed Page Converted (Check Stats) </td> <td bgcolor="#FFFFFF" name="column-heading_referral-page-converted">Referral Page Converted (Visit Page) </td> <td bgcolor="#FFFFFF" name="column-heading_referral-page-converted">Referral Page Converted (Check Stats) </td> <td bgcolor="#FFFFFF" name="column-heading_username">Followee Username (Visit Page)</td> <td bgcolor="#FFFFFF" name="column-heading_username">Followee Username (Check Stats)</td> <td bgcolor="#FFFFFF" name="column-heading_username">Follower Username (Visit Page)</td> <td bgcolor="#FFFFFF" name="column-heading_username">Follower Username (Check Stats)</td> <td bgcolor="#FFFFFF" name="column-heading_gender">Gender</td> <td bgcolor="#FFFFFF" name="column-heading_age-range">Age Range</td> <td bgcolor="#FFFFFF" name="column-heading_date-of-birth">Date Of Birth</td> <td bgcolor="#FFFFFF" name="column-heading_skin-complexion">Skin Complexion</td> <td bgcolor="#FFFFFF" name="column-heading_height">Height</td> <td bgcolor="#FFFFFF" name="column-heading_weight">Weight</td> <td bgcolor="#FFFFFF" name="column-heading_sexual-orientation">Sexual Orientation</td> <td bgcolor="#FFFFFF" name="column-heading_religion">Religion</td> <td bgcolor="#FFFFFF" name="column-heading_education">Education</td> <td bgcolor="#FFFFFF" name="column-heading_profession">Profession</td> <td bgcolor="#FFFFFF" name="column-heading_marital-status">Marital Status</td> <td bgcolor="#FFFFFF" name="column-heading_working-status">Working Status</td> <td bgcolor="#FFFFFF" name="column-heading_country-of-birth">Country Of Birth</td> <td bgcolor="#FFFFFF" name="column-heading_home-town">Home Town</td> <td bgcolor="#FFFFFF" name="column-heading_home-neighbourhood">Home Neighbourhood</td> <td bgcolor="#FFFFFF" name="column-heading_home-borough">Home Borough</td> <td bgcolor="#FFFFFF" name="column-heading_home-city">Home City</td> <td bgcolor="#FFFFFF" name="column-heading_home-county">Home County</td> <td bgcolor="#FFFFFF" name="column-heading_home-district">Home District</td> <td bgcolor="#FFFFFF" name="column-heading_home-region">Home Region</td> <td bgcolor="#FFFFFF" name="column-heading_home-state">Home State</td> <td bgcolor="#FFFFFF" name="column-heading_home-country">Home Country</td> </tr> <?php while($row = mysqli_fetch_array($result)) { ?> <tr name="user-details"> <td bgcolor="#FFFFFF" name="submission-number"><a href="following_histories_v1.php?followee_id=<?php echo $row['id']; ?>&page_number=1"><?php echo $row['id']; ?></a></td> <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><a href="following_histories_v1.php?followee_date_and_time=<?php echo $row['date_and_time']; ?>&page_number=1"><?php echo $row['date_and_time']; ?></a></td> <td bgcolor="#FFFFFF" name="browsed-page-converted_visit-page"><a href="<?php echo $row['followed_page_converted']; ?>&page_number=1"><?php echo $row['followed_page_converted']; ?></a></td> <td bgcolor="#FFFFFF" name="browsed-page-converted_stats-page"><a href="following_histories_v1.php?followee_followed_page_converted=<?php echo $row['followed_page_converted']; ?>&page_number=1"><?php echo $row['followed_page_converted']; ?></a></td> <td bgcolor="#FFFFFF" name="referral-page-converted_visit-page"><a href="<?php echo $row['referral_page_converted']; ?>&page_number=1"><?php echo $row['referral_page_converted']; ?></a></td> <td bgcolor="#FFFFFF" name="referral-page-converted_stats-page"><a href="following_histories_v1.php?followee_referral_page_converted=<?php echo $row['referral_page_converted']; ?>&page_number=1"><?php echo $row['referral_page_converted']; ?></a></td> <td bgcolor="#FFFFFF" name="profile-page-followee_visit-page"><a href="profile.php?followee_username=<?php echo $row['followee_username']; ?>&page_number=1"><?php echo $row['followee_username']; ?></a></td> <td bgcolor="#FFFFFF" name="profile-page-followee_stats-page"><a href="following_histories_v1.php?followee_username=<?php echo $row['followee_username']; ?>&page_number=1"><?php echo $row['followee_username']; ?></a></td> <td bgcolor="#FFFFFF" name="profile-page-follower_visit-page"><a href="profile.php?followee_username=<?php echo $row['follower_username']; ?>&page_number=1"><?php echo $row['follower_username']; ?></a></td> <td bgcolor="#FFFFFF" name="profile-page-follower_stats-page"><a href="following_histories_v1.php?followee_username=<?php echo $row['follower_username']; ?>&page_number=1"><?php echo $row['follower_username']; ?></a></td> <td bgcolor="#FFFFFF" name="gender"><a href="following_histories_v1.php?followee_gender=<?php echo $row['gender']; ?>&page_number=1"><?php echo $row['gender']; ?></a></td> <td bgcolor="#FFFFFF" name="age-range"><a href="following_histories_v1.php?followee_age_range=<?php echo $row['age_range']; ?>&page_number=1"><?php echo $row['age_range']; ?></a></td> <td bgcolor="#FFFFFF" name="date-of-birth"><a href="following_histories_v1.php?followee_date_of_birth=<?php echo $row['date_of_birth']; ?>&page_number=1"><?php echo $row['date_of_birth']; ?></a></td> <td bgcolor="#FFFFFF" name="skin-complexion"><a href="following_histories_v1.php?followee_skin_complexion=<?php echo $row['skin_complexion']; ?>&page_number=1"><?php echo $row['skin_complexion']; ?></a></td> <td bgcolor="#FFFFFF" name="height"><a href="following_histories_v1.php?followee_height=<?php echo $row['height']; ?>&page_number=1"><?php echo $row['height']; ?></a></td> <td bgcolor="#FFFFFF" name="weight"><a href="following_histories_v1.php?followee_height=<?php echo $row['weight']; ?>&page_number=1"><?php echo $row['weight']; ?></a></td> <td bgcolor="#FFFFFF" name="sexual-orientation"><a href="following_histories_v1.php?followee_sexual_orientation=<?php echo $row['sexual_orientation']; ?>&page_number=1"><?php echo $row['sexual_orientation']; ?></a></td> <td bgcolor="#FFFFFF" name="religion"><a href="following_histories_v1.php?followee_religion=<?php echo $row['religion']; ?>&page_number=1"><?php echo $row['religion']; ?></a></td> <td bgcolor="#FFFFFF" name="education"><a href="following_histories_v1.php?followee_education=<?php echo $row['education']; ?>&page_number=1"><?php echo $row['education']; ?></a></td> <td bgcolor="#FFFFFF" name="profession"><a href="following_histories_v1.php?followee_profession=<?php echo $row['profession']; ?>&page_number=1"><?php echo $row['profession']; ?></a></td> <td bgcolor="#FFFFFF" name="marital-status"><a href="following_histories_v1.php?followee_marital_status=<?php echo $row['marital_status']; ?>&page_number=1"><?php echo $row['marital_status']; ?></a></td> <td bgcolor="#FFFFFF" name="working-status"><a href="following_histories_v1.php?followee_working_status=<?php echo $row['working_status']; ?>&page_number=1"><?php echo $row['working_status']; ?></a></td> <td bgcolor="#FFFFFF" name="country-of-birth"><a href="following_histories_v1.php?followee_country_of_birth=<?php echo $row['country_of_birth']; ?>&page_number=1"><?php echo $row['country_of_birth']; ?></a></td> <td bgcolor="#FFFFFF" name="home-town"><a href="following_histories_v1.php?followee_home_town=<?php echo $row['home_town']; ?>&page_number=1"><?php echo $row['home_town']; ?></a></td> <td bgcolor="#FFFFFF" name="home-neighbourhood"><a href="following_histories_v1.php?followee_home_neighbourhood=<?php echo $row['home_neighbourhood']; ?>&page_number=1"><?php echo $row['home_neighbourhood']; ?></a></td> <td bgcolor="#FFFFFF" name="home-borough"><a href="following_histories_v1.php?followee_home_borough=<?php echo $row['home_borough']; ?>&page_number=1"><?php echo $row['home_borough']; ?></a></td> <td bgcolor="#FFFFFF" name="home-city"><a href="following_histories_v1.php?followee_home_city=<?php echo $row['home_city']; ?>&page_number=1"><?php echo $row['home_city']; ?></a></td> <td bgcolor="#FFFFFF" name="home-county"><a href="following_histories_v1.php?followee_home_county=<?php echo $row['home_county']; ?>&page_number=1"><?php echo $row['home_county']; ?></a></td> <td bgcolor="#FFFFFF" name="home-district"><a href="following_histories_v1.php?followee_home_district=<?php echo $row['home_district']; ?>&page_number=1"><?php echo $row['home_district']; ?></a></td> <td bgcolor="#FFFFFF" name="home-region"><a href="following_histories_v1.php?followee_home_region=<?php echo $row['home_region']; ?>&page_number=1"><?php echo $row['home_region']; ?></a></td> <td bgcolor="#FFFFFF" name="home-state"><a href="following_histories_v1.php?followee_home_state=<?php echo $row['home_state']; ?>&page_number=1"><?php echo $row['home_state']; ?></a></td> <td bgcolor="#FFFFFF" name="home-country"><a href="following_histories_v1.php?followee_home_country=<?php echo $row['home_country']; ?>&page_number=1"><?php echo $row['home_country']; ?></a></td> </tr> <?php } ?> <tr name="pagination"> <td colspan="30" bgcolor="#FFFFFF"> Result Pages: <?php if($rows_num <= $page_size) { echo "Page 1"; } else { for($i=1;$i<=$page_count;$i++) echo "<a href=\"{$_SERVER['PHP_SELF']}?$query_type=${$query_type}&page_number={$i}\">{$i}</a> "; } ?> </td> </tr> <?php } else { ?> <tr> <td bgcolor="#FFFFFF">No record found! Try another time.</td> </tr> <?php } ?> </table> <br> <br> <p align="center"><span style="font-weight:bold;"><?php echo "Search Result for:<br> $query_type_label = \"${$query_type}\""; ?></span></p> <br> <br> <br> </body> </html>
The ISSUE STARTS as soon as I try adding PREP STMT. Here is my attempt so far:
<?php //Required PHP Files. include 'header_account.php'; //Required on all webpages of the Account. ?> <?php if (!$conn) { $error = mysqli_connect_error(); $errno = mysqli_connect_errno(); print "$errno: $error\n"; exit(); } //Grab Username of who's Browsing History needs to be searched. if (isset($_GET['followee_username']) && !empty($_GET['followee_username'])) { $followee_username = $_GET['followee_username']; if($followee_username != 'followee_all' OR $followee_username != 'Followee_All') { //$query = "SELECT * FROM browsing_histories WHERE username = \"$followee_username\""; $query_type = "followee_username"; $followed_word = "$followee_username"; //$followee_username = "$followee_username"; $query = "SELECT id,date_and_time,query_type,followed_word,query_string,followed_page_original,followed_page_converted,referral_page_original,referral_page_converted,followee_username,follower_username,gender,age_range,date_of_birth,skin_complexion,height,weight,sexual_orientation,religion,education,profession,marital_status,working_status,home_town,home_neighbourhood,home_borough,home_council,home_city,home_county,home_district,home_region,home_state,home_country FROM following_histories WHERE followee_username = ?"; $stmt = mysqli_prepare($conn,$query); mysqli_stmt_bind_param($stmt,'s',$followee_username); mysqli_stmt_execute($stmt); //Check if User's details was successfully extracted or not from 'details_contact_home' tbl. if (!$stmt) { echo "ERROR 3: Sorry! Our system is currently experiencing a problem logging you in!"; exit(); } else { $result = mysqli_stmt_bind_result($stmt,$followee_browsing_history_submission_id,$followee_browsing_history_submission_date_and_time,$followee_query_type,$followee_followed_word,$followee_query_string,$followee_browsed_page_original,$followee_browsed_page_converted,$followee_referral_page_original,$followee_referral_page_converted,$followee_username,$followee_gender,$followee_age_range,$followee_date_of_birth,$followee_skin_complexion,$followee_height,$followee_weight,$followee_sexual_orientation,$followee_religion,$followee_education,$followee_profession,$followee_marital_status,$followee_working_status,$followee_country_of_birth,$followee_home_town,$followee_home_neighbourhood,$followee_home_borough,$followee_home_council,$followee_home_city,$followee_home_county,$followee_home_district,$followee_home_region,$followee_home_state,$followee_home_country); mysqli_stmt_fetch($stmt); mysqli_stmt_close($stmt); } } else { $query = "SELECT * FROM following_histories"; $query_type = "followee_all"; $followed_word = "followee_all"; echo "all"; echo "all search"; } } if (isset($_GET['follower_username']) && !empty($_GET['follower_username'])) { $follower_username = $_GET['follower_username']; if($follower_username != 'follower_all' OR $follower_username != 'Follower_All') { //$query = "SELECT * FROM browsing_histories WHERE username = \"$follower_username\""; $query_type = "follower_username"; $followed_word = "$follower_username"; $query = "SELECT id,date_and_time,query_type,followed_word,query_string,followed_page_original,followed_page_converted,referral_page_original,referral_page_converted,followee_username,follower_username,gender,age_range,date_of_birth,skin_complexion,height,weight,sexual_orientation,religion,education,profession,marital_status,working_status,followee_country_of_birth,home_town,home_neighbourhood,home_borough,home_council,home_city,home_county,home_district,home_region,home_state,home_country FROM browsing_histories WHERE followee_username = ?"; $stmt = mysqli_prepare($conn,$query); mysqli_stmt_bind_param($stmt,'s',$follower_username); mysqli_stmt_execute($stmt); //Check if User's details was successfully extracted or not from 'details_contact_home' tbl. if (!$stmt) { echo "ERROR 3: Sorry! Our system is currently experiencing a problem logging you in!"; exit(); } else { $result = mysqli_stmt_bind_result($stmt,$followee_browsing_history_submission_id,$followee_browsing_history_submission_date_and_time,$followee_query_type,$followee_followed_word,$followee_query_string,$followee_browsed_page_original,$followee_browsed_page_converted,$followee_referral_page_original,$followee_referral_page_converted,$followee_username,$followee_gender,$followee_age_range,$followee_date_of_birth,$followee_skin_complexion,$followee_height,$followee_weight,$followee_sexual_orientation,$followee_religion,$followee_education,$followee_profession,$followee_marital_status,$followee_working_status,$followee_country_of_birth,$followee_home_town,$followee_home_neighbourhood,$followee_home_borough,$followee_home_council,$followee_home_city,$followee_home_county,$followee_home_district,$followee_home_region,$followee_home_state,$followee_home_country); mysqli_stmt_fetch($stmt); mysqli_stmt_close($stmt); } } else { $query = "SELECT * FROM following_histories"; $query_type = "follower_all"; $followed_word = "follower_all"; echo "all"; echo "all search"; } } if (isset($_GET['followee_id']) && !empty($_GET['followee_id'])) { $followee_id = $_GET['followee_id']; $query = "SELECT * FROM following_histories WHERE id = \"$followee_id\""; $query_type = "followee_id"; $followed_word = "$followee_id"; echo "$followee_id"; } if (isset($_GET['followee_date_and_time']) && !empty($_GET['followee_date_and_time'])) { $followee_date_and_time = $_GET['followee_date_and_time']; $query = "SELECT * FROM following_histories WHERE date_and_time = \"$followee_date_and_time\""; $query_type = "followee_date_and_time"; $followed_word = "$followee_date_and_time"; } if (isset($_GET['followee_followed_page_converted']) && !empty($_GET['followee_followed_page_converted'])) { $followee_followed_page_converted = $_GET['followee_followed_page_converted']; $query = "SELECT * FROM following_histories WHERE followed_page_converted = \"$followee_followed_page_converted\""; $query_type = "followee_followed_page_converted"; $followed_word = "$followee_followed_page_converted"; } if (isset($_GET['followee_referral_page_converted']) && !empty($_GET['followee_referral_page_converted'])) { $followee_referral_page_converted = $_GET['followee_referral_page_converted']; $query = "SELECT * FROM following_histories WHERE referral_page_converted = \"$followee_referral_page_converted\""; $query_type = "followee_referral_page_converted"; $followed_word = "$followee_referral_page_converted"; } if (isset($_GET['followee_gender']) && !empty($_GET['followee_gender'])) { $followee_gender = $_GET['followee_gender']; $query = "SELECT * FROM following_histories WHERE gender = \"$followee_gender\""; $query_type = "followee_gender"; $followed_word = "$followee_gender"; } if (isset($_GET['followee_age_range']) && !empty($_GET['followee_age_range'])) { $followee_age_range = $_GET['followee_age_range']; $query = "SELECT * FROM following_histories WHERE age_range = \"$followee_age_range\""; $query_type = "followee_age_range"; $followed_word = "$followee_age_range"; } if (isset($_GET['followee_date_of_birth']) && !empty($_GET['followee_date_of_birth'])) { $followee_date_of_birth = $_GET['followee_date_of_birth']; $query = "SELECT * FROM following_histories WHERE date_of_birth = \"$followee_date_of_birth\""; $query_type = "followee_date_of_birth"; $followed_word = "$followee_date_of_birth"; } if (isset($_GET['followee_skin_complexion']) && !empty($_GET['followee_skin_complexion'])) { $followee_skin_complexion = $_GET['followee_skin_complexion']; $query = "SELECT * FROM following_histories WHERE skin_complexion = \"$followee_skin_complexion\""; $query_type = "followee_skin_complexion"; $followed_word = "$followee_skin_complexion"; } if (isset($_GET['followee_height']) && !empty($_GET['followee_height'])) { $followee_height = $_GET['followee_height']; $query = "SELECT * FROM following_histories WHERE height = \"$followee_height\""; $query_type = "followee_height"; $followed_word = "$followee_height"; } if (isset($_GET['followee_weight']) && !empty($_GET['followee_weight'])) { $followee_weight = $_GET['followee_weight']; $query = "SELECT * FROM following_histories WHERE weight = \"$followee_weight\""; $query_type = "followee_weight"; $followed_word = "$followee_weight"; } if (isset($_GET['followee_sexual_orientation']) && !empty($_GET['followee_sexual_orientation'])) { $followee_sexual_orientation = $_GET['followee_sexual_orientation']; $query = "SELECT * FROM following_histories WHERE sexual_orientation = \"$followee_sexual_orientation\""; $query_type = "followee_sexual_orientation"; $followed_word = "$followee_sexual_orientation"; } if (isset($_GET['followee_religion']) && !empty($_GET['followee_religion'])) { $followee_religion = $_GET['followee_religion']; $query = "SELECT * FROM following_histories WHERE religion = \"$followee_religion\""; $query_type = "followee_religion"; $followed_word = "$followee_religion"; } if (isset($_GET['followee_education']) && !empty($_GET['followee_education'])) { $followee_education = $_GET['followee_education']; $query = "SELECT * FROM following_histories WHERE education = \"$followee_education\""; $query_type = "followee_education"; $followed_word = "$followee_education"; } if (isset($_GET['followee_profession']) && !empty($_GET['followee_profession'])) { $followee_profession = $_GET['followee_profession']; $query = "SELECT * FROM following_histories WHERE profession = \"$followee_profession\""; $query_type = "followee_profession"; $followed_word = "$followee_profession"; } if (isset($_GET['followee_marital_status']) && !empty($_GET['followee_marital_status'])) { $followee_marital_status = $_GET['followee_marital_status']; $query = "SELECT * FROM following_histories WHERE marital_status = \"$followee_marital_status\""; $query_type = "followee_marital_status"; $followed_word = "$followee_marital_status"; } if (isset($_GET['followee_working_status']) && !empty($_GET['followee_working_status'])) { $followee_working_status = $_GET['followee_working_status']; $query = "SELECT * FROM following_histories WHERE working_status = \"$followee_working_status\""; $query_type = "followee_working_status"; $followed_word = "$followee_working_status"; } if (isset($_GET['followee_country_of_birth']) && !empty($_GET['followee_country_of_birth'])) { $followee_country_of_birth = $_GET['followee_country_of_birth']; $query = "SELECT * FROM following_histories WHERE country_of_birth = \"$followee_country_of_birth\""; $query_type = "followee_country_of_birth"; $followed_word = "$followee_country_of_birth"; } if (isset($_GET['followee_home_town']) && !empty($_GET['followee_home_town'])) { $followee_home_town = $_GET['followee_home_town']; $query = "SELECT * FROM following_histories WHERE home_town = \"$followee_home_town\""; $query_type = "followee_home_town"; $followed_word = "$followee_home_town"; } if (isset($_GET['followee_home_neighbourhood']) && !empty($_GET['followee_home_neighbourhood'])) { $followee_home_neighbourhood = $_GET['followee_home_neighbourhood']; $query = "SELECT * FROM following_histories WHERE home_neighbourhood = \"$followee_home_neighbourhood\""; $query_type = "followee_home_neighbourhood"; $followed_word = "$followee_home_neighbourhood"; } if (isset($_GET['followee_home_borough']) && !empty($_GET['followee_home_borough'])) { $followee_home_borough = $_GET['followee_home_borough']; $query = "SELECT * FROM following_histories WHERE home_borough = \"$followee_home_borough\""; $query_type = "followee_home_borough"; $followed_word = "$followee_home_borough"; } if (isset($_GET['followee_home_city']) && !empty($_GET['followee_home_city'])) { $followee_home_city = $_GET['followee_home_city']; $query = "SELECT * FROM following_histories WHERE home_city = \"$followee_home_city\""; $query_type = "followee_home_city"; $followed_word = "$followee_home_city"; } if (isset($_GET['followee_home_county']) && !empty($_GET['followee_home_county'])) { $followee_home_county = $_GET['followee_home_county']; $query = "SELECT * FROM following_histories WHERE home_county = \"$followee_home_county\""; $query_type = "followee_home_county"; $followed_word = "$followee_home_county"; } if (isset($_GET['followee_home_district']) && !empty($_GET['followee_home_district'])) { $followee_home_district = $_GET['followee_home_district']; $query = "SELECT * FROM following_histories WHERE home_district = \"$followee_home_district\""; $query_type = "followee_home_district"; $followed_word = "$followee_home_district"; } if (isset($_GET['followee_home_region']) && !empty($_GET['followee_home_region'])) { $followee_home_region = $_GET['followee_home_region']; $query = "SELECT * FROM following_histories WHERE home_region = \"$followee_home_region\""; $query_type = "followee_home_region"; $followed_word = "$followee_home_region"; } if (isset($_GET['followee_home_state']) && !empty($_GET['followee_home_state'])) { $followee_home_state = $_GET['followee_home_state']; $query = "SELECT * FROM following_histories WHERE home_state = \"$followee_home_state\""; $query_type = "followee_home_state"; $followed_word = "$followee_home_state"; } if (isset($_GET['followee_home_country']) && !empty($_GET['followee_home_country'])) { $followee_home_country = $_GET['followee_home_country']; $query = "SELECT * FROM following_histories WHERE home_country = \"$followee_home_country\""; $query_type = "followee_home_country"; $followed_word = "$followee_home_country"; } $referral_page_http = $_SERVER['HTTP_REFERRER']; $referral_page = "$referral_page_http"; $referral_page_original = "$referral_page"; $query_string = $_SERVER['QUERY_STRING']; $current_page_http = $_SERVER['PHP_SELF']; $current_page = "$current_page_http"; $followed_page_original = "$current_page"; $visiting_pages_count = "1"; if($visiting_pages_count == "") { $visiting_pages_count = "1"; } else { $visiting_pages_count++; } if($visiting_pages_count == "1") { $current_page_converted = "$settings_user_first_quick_link.$current_page"; $referral_page_converted = "$settings_user_first_quick_link.$referral_page"; } elseif($visiting_pages_count == "2") { $current_page_converted = "$settings_admin_second_quick_link.$current_page"; $referral_page_converted = "$settings_admin_second_quick_link.$referral_page"; } elseif($visiting_pages_count == "3") { $current_page_converted = "$settings_user_third_quick_link.$current_page"; $referral_page_converted = "$settings_user_third_quick_link.$referral_page"; } elseif($visiting_pages_count == "4") { $current_page_converted = "$settings_admin_fourth_quick_link.$current_page"; $referral_page_converted = "$settings_admin_fourth_quick_link.$referral_page"; } elseif($visiting_pages_count == "5") { $current_page_converted = "$settings_user_fifth_quick_link.$current_page"; $referral_page_converted = "$settings_user_fifth_quick_link.$referral_page"; } if($visiting_pages_count == "6") { $current_page_converted = "$settings_admin_first_quick_link.$current_page"; $referral_page_converted = "$settings_admin_first_quick_link.$referral_page"; } elseif($visiting_pages_count == "7") { $current_page_converted = "$settings_user_second_quick_link.$current_page"; $referral_page_converted = "$settings_user_second_quick_link.$referral_page"; } elseif($visiting_pages_count == "8") { $current_page_converted = "$settings_admin_third_quick_link.$current_page"; $referral_page_converted = "$settings_admin_third_quick_link.$referral_page"; } elseif($visiting_pages_count == "9") { $current_page_converted = "$settings_user_fourth_quick_link.$current_page"; $referral_page_converted = "$settings_user_fourth_quick_link.$referral_page"; } elseif($visiting_pages_count == "10") { $current_page_converted = "$settings_admin_fifth_quick_link.$current_page"; $referral_page_converted = "$settings_admin_fifth_quick_link.$referral_page"; } else { $visiting_pages_count = "1"; $current_page_converted = "$settings_user_first_quick_link.$current_page"; $referral_page_converted = "$settings_user_first_quick_link.$referral_page"; } $followed_page_converted = "$current_page_converted"; $follower_username = $user; $follower_browser = $_SERVER['HTTP_USER_AGENT']; //Insert the User's Click Logs into Mysql Database using Php's Sql Injection Prevention Method "Prepared Statements". $stmt_2 = mysqli_prepare($conn,"INSERT INTO following_histories(query_type,followed_word,query_string,followed_page_original,followed_page_converted,referral_page_original,referral_page_converted,followee_username,follower_username,gender,age_range,date_of_birth,skin_complexion,height,weight,sexual_orientation,religion,education,profession,marital_status,working_status,country_of_birth,home_town,home_neighbourhood,home_borough,home_council,home_city,home_county,home_district,home_region,home_state,home_country) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); mysqli_stmt_bind_param($stmt_2,'ssssssssssiissssssssssssssssssss',$query_type,$followed_word,$query_string,$followed_page_original,$followed_page_converted,$referral_page_original,$referral_page_converted,$followee_username,$follower_username,$gender,$age_range,$date_of_birth,$skin_complexion,$height,$weight,$sexual_orientation,$religion,$education,$profession,$marital_status,$working_status,$country_of_birth,$home_town,$home_neighbourhood,$home_borough,$home_council,$home_city,$home_county,$home_district,$home_region,$home_state,$home_country); mysqli_stmt_execute($stmt_2); //Check if User's Click Logs have been successfully submitted or not. if (!$stmt_2) { echo "Sorry! Our system is currently experiencing a problem logging your following! We will continuously try logging your clicks!"; exit(); } else { mysqli_stmt_fetch($stmt_2); mysqli_stmt_close($stmt_2); } $query_type_label = str_replace("_"," ","$query_type"); //Removing underscores so they don't show-up on the html. $query_type_label = ucwords("$query_type_label"); //Upper Casing the first characters. ?> <!DOCTYPE html> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv=" content-type"> <title><?php echo "Browsing History in $server_time Time.";?></title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <br> <p align="center"><span style="font-weight:bold;"><?php echo "Search Result for:<br> $query_type_label = \"${$query_type}\""; ?></span></p> <br> <br> <?php $result = mysqli_query($conn,$query); $rows_num = mysqli_num_rows($result); //Total Number of Pages records are spread-over. $page_count = 100; $page_size = ceil($rows_num / $page_count); //Get the Page Number. Default is 1 (First Page). $page_number = $_GET["page_number"]; if ($page_number == "") $page_number = 1; $offset = ($page_number -1) * $page_size; $query .= " limit {$offset},{$page_size}"; $result = mysqli_query($conn,$query); ?> <table width="1500" border="0" cellpadding="5" cellspacing="2" bgcolor="#666666"> <?php if(!$rows_num) { ?> <tr> <td bgcolor="#FFFFFF">No record found! Try another time.</td> </tr> <?php } else { printf("<b> %d Result Found ...</b>\n",$rows_num); ?><br> <br> <tr name="headings"> <td bgcolor="#FFFFFF" name="column-heading_submission-number">Submission Number</td> <td bgcolor="#FFFFFF" name="column-heading_logging-server-date-and-time">Date & Time in <?php echo "$server_time";?></td> <td bgcolor="#FFFFFF" name="column-heading_browsed-page-converted">Browsed Page Converted (Visit Page) </td> <td bgcolor="#FFFFFF" name="column-heading_browsed-page-converted">Browsed Page Converted (Check Stats) </td> <td bgcolor="#FFFFFF" name="column-heading_referral-page-converted">Referral Page Converted (Visit Page) </td> <td bgcolor="#FFFFFF" name="column-heading_referral-page-converted">Referral Page Converted (Check Stats) </td> <td bgcolor="#FFFFFF" name="column-heading_username">Followee Username (Visit Page)</td> <td bgcolor="#FFFFFF" name="column-heading_username">Followee Username (Check Stats)</td> <td bgcolor="#FFFFFF" name="column-heading_username">Follower Username (Visit Page)</td> <td bgcolor="#FFFFFF" name="column-heading_username">Follower Username (Check Stats)</td> <td bgcolor="#FFFFFF" name="column-heading_gender">Follower Gender</td> <td bgcolor="#FFFFFF" name="column-heading_age-range">Follower Age Range</td> <td bgcolor="#FFFFFF" name="column-heading_date-of-birth">Follower Date Of Birth</td> <td bgcolor="#FFFFFF" name="column-heading_skin-complexion">Follower Skin Complexion</td> <td bgcolor="#FFFFFF" name="column-heading_height">Follower Height</td> <td bgcolor="#FFFFFF" name="column-heading_weight">Follower Weight</td> <td bgcolor="#FFFFFF" name="column-heading_sexual-orientation">Follower Sexual Orientation</td> <td bgcolor="#FFFFFF" name="column-heading_religion">Follower Religion</td> <td bgcolor="#FFFFFF" name="column-heading_education">Follower Education</td> <td bgcolor="#FFFFFF" name="column-heading_profession">Follower Profession</td> <td bgcolor="#FFFFFF" name="column-heading_marital-status">Follower Marital Status</td> <td bgcolor="#FFFFFF" name="column-heading_working-status">Follower Working Status</td> <td bgcolor="#FFFFFF" name="column-heading_country-of-birth">Follower Country Of Birth</td> <td bgcolor="#FFFFFF" name="column-heading_home-town">Follower Home Town</td> <td bgcolor="#FFFFFF" name="column-heading_home-neighbourhood">Follower Home Neighbourhood</td> <td bgcolor="#FFFFFF" name="column-heading_home-borough">Follower Home Borough</td> <td bgcolor="#FFFFFF" name="column-heading_home-city">Follower Home City</td> <td bgcolor="#FFFFFF" name="column-heading_home-county">Follower Home County</td> <td bgcolor="#FFFFFF" name="column-heading_home-district">Follower Home District</td> <td bgcolor="#FFFFFF" name="column-heading_home-region">Follower Home Region</td> <td bgcolor="#FFFFFF" name="column-heading_home-state">Follower Home State</td> <td bgcolor="#FFFFFF" name="column-heading_home-country">Follower Home Country</td> </tr> <?php while($row = mysqli_fetch_array($result)) { ?> <tr name="user-details"> <td bgcolor="#FFFFFF" name="submission-number"><a href="following_histories_v1.php?followee_id=<?php echo $followee_browsing_history_submission_id; ?>&page_number=1"><?php echo $followee_browsing_history_submission_id; ?></a></td> <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><a href="following_histories_v1.php?followee_date_and_time=<?php echo $followee_browsing_history_submission_date_and_time; ?>&page_number=1"><?php echo $followee_browsing_history_submission_date_and_time; ?></a></td> <td bgcolor="#FFFFFF" name="followed-page-converted_visit-page"><a href="<?php echo "followee_browser.php?followee_username=$followee_username&followee_followed_page_converted=$followee_followed_page_converted"; ?>"><?php echo "$followee_followed_page_converted"; ?></a></td> <td bgcolor="#FFFFFF" name="followed-page-converted_stats-page"><a href="following_histories_v1.php?followee_followed_page_converted=<?php echo "$followee_followed_page_converted"; ?>&page_number=1"><?php echo "$followee_followed_page_converted"; ?></a></td> <td bgcolor="#FFFFFF" name="referral-page-converted_visit-page"><a href="<?php echo "followee_browser.php?followee_username=$followee_username&followee_referral_page_converted=$followee_referral_page_converted"; ?>"><?php echo "$followee_referral_page_converted"; ?></a></td> <td bgcolor="#FFFFFF" name="referral-page-converted_stats-page"><a href="following_histories_v1.php?followee_referral_page_converted=<?php echo "$followee_referral_page_converted"; ?>&page_number=1"><?php echo "$followee_referral_page_converted"; ?></a></td> <td bgcolor="#FFFFFF" name="profile-page-followee_visit-page"><a href="profile.php?followee_username=<?php echo "$followee_username"; ?>"><?php echo "$followee_username"; ?></a></td> <td bgcolor="#FFFFFF" name="profile-page-followee_stats-page"><a href="following_histories_v1.php?followee_username=<?php echo "$followee_username"; ?>"><?php echo "$followee_username"; ?></a></td> <td bgcolor="#FFFFFF" name="profile-page-follower_visit-page"><a href="profile.php?followee_username=<?php echo "$follower_username"; ?>"><?php echo "$follower_username"; ?></a></td> <td bgcolor="#FFFFFF" name="profile-page-follower_stats-page"><a href="following_histories_v1.php?followee_username=<?php echo "$follower_username"; ?>"><?php echo "$follower_username"; ?></a></td> <td bgcolor="#FFFFFF" name="gender"><a href="following_histories_v1.php?followee_gender=<?php echo "$follower_gender"; ?>&page_number=1"><?php echo "$follower_gender"; ?></a></td> <td bgcolor="#FFFFFF" name="age-range"><a href="following_histories_v1.php?followee_age_range=<?php echo "$follower_age_range"; ?>&page_number=1"><?php echo "$followerage_range"; ?></a></td> <td bgcolor="#FFFFFF" name="date-of-birth"><a href="following_histories_v1.php?followee_date_of_birth=<?php echo "$follower_date_of_birth"; ?>&page_number=1"><?php echo "$follower_date_of_birth"; ?></a></td> <td bgcolor="#FFFFFF" name="skin-complexion"><a href="following_histories_v1.php?followee_skin_complexion=<?php echo "$follower_skin_complexion"; ?>&page_number=1"><?php echo "$follower_skin_complexion"; ?></a></td> <td bgcolor="#FFFFFF" name="height"><a href="following_histories_v1.php?followee_height=<?php echo "$follower_height"; ?>&page_number=1"><?php echo "$follower_height"; ?></a></td> <td bgcolor="#FFFFFF" name="weight"><a href="following_histories_v1.php?followee_height=<?php echo "$follower_weight"; ?>&page_number=1"><?php echo "$follower_weight"; ?></a></td> <td bgcolor="#FFFFFF" name="sexual-orientation"><a href="following_histories_v1.php?followee_sexual_orientation=<?php echo "$follower_sexual_orientation"; ?>&page_number=1"><?php echo "$follower_sexual_orientation"; ?></a></td> <td bgcolor="#FFFFFF" name="religion"><a href="following_histories_v1.php?followee_religion=<?php echo "$follower_religion"; ?>&page_number=1"><?php echo "$follower_religion"; ?></a></td> <td bgcolor="#FFFFFF" name="education"><a href="following_histories_v1.php?followee_education=<?php echo "$follower_education"; ?>&page_number=1"><?php echo "$follower_education"; ?></a></td> <td bgcolor="#FFFFFF" name="profession"><a href="following_histories_v1.php?followee_profession=<?php echo "$follower_profession"; ?>&page_number=1"><?php echo "$follower_profession"; ?></a></td> <td bgcolor="#FFFFFF" name="marital-status"><a href="following_histories_v1.php?followee_marital_status=<?php echo "$follower_marital_status"; ?>&page_number=1"><?php echo "$follower_marital_status"; ?></a></td> <td bgcolor="#FFFFFF" name="working-status"><a href="following_histories_v1.php?followee_working_status=<?php echo "$follower_working_status"; ?>&page_number=1"><?php echo "$follower_working_status"; ?></a></td> <td bgcolor="#FFFFFF" name="country-of-birth"><a href="following_histories_v1.php?followee_country_of_birth=<?php echo "$follower_country_of_birth"; ?>&page_number=1"><?php echo "$follower_country_of_birth"; ?></a></td> <td bgcolor="#FFFFFF" name="home-town"><a href="following_histories_v1.php?followee_home_town=<?php echo "$follower_home_town"; ?>&page_number=1"><?php echo "$follower_home_town"; ?></a></td> <td bgcolor="#FFFFFF" name="home-neighbourhood"><a href="following_histories_v1.php?followee_home_neighbourhood=<?php echo "$follower_home_neighbourhood"; ?>&page_number=1"><?php echo "$home_neighbourhood"; ?></a></td> <td bgcolor="#FFFFFF" name="home-borough"><a href="following_histories_v1.php?followee_home_borough=<?php echo "$follower_home_borough"; ?>&page_number=1"><?php echo "$follower_home_borough"; ?></a></td> <td bgcolor="#FFFFFF" name="home-city"><a href="following_histories_v1.php?followee_home_city=<?php echo "$follower_home_city"; ?>&page_number=1"><?php echo "$follower_home_city"; ?></a></td> <td bgcolor="#FFFFFF" name="home-county"><a href="following_histories_v1.php?followee_home_county=<?php echo "$follower_home_county"; ?>&page_number=1"><?php echo "$follower_home_county"; ?></a></td> <td bgcolor="#FFFFFF" name="home-district"><a href="following_histories_v1.php?followee_home_district=<?php echo "$follower_home_district"; ?>&page_number=1"><?php echo "$follower_home_district"; ?></a></td> <td bgcolor="#FFFFFF" name="home-region"><a href="following_histories_v1.php?followee_home_region=<?php echo "$follower_home_region"; ?>&page_number=1"><?php echo "$follower_home_region"; ?></a></td> <td bgcolor="#FFFFFF" name="home-state"><a href="following_histories_v1.php?followee_home_state=<?php echo "$follower_home_state"; ?>&page_number=1"><?php echo "$follower_home_state"; ?></a></td> <td bgcolor="#FFFFFF" name="home-country"><a href="following_histories_v1.php?followee_home_country=<?php echo "$follower_home_country"; ?>&page_number=1"><?php echo "$follower_home_country"; ?></a></td> </tr> <?php } ?> <tr name="pagination"> <td colspan="30" bgcolor="#FFFFFF"> Result Pages: <?php if($rows_num <= $page_size) { echo "Page 1"; } else { for($i=1;$i<=$page_count;$i++) echo "<a href=\"{$_SERVER['PHP_SELF']}?$query_type=${$query_type}&page_number={$i}\">{$i}</a> "; } ?> </td&g I have the following php code that errors as indicated: $query = $con->query('SELECT FILENAME, country, area, city FROM download WHERE FILENAME is not null'); Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'country' in 'field list' in /home/larry/web/test/public_html/report1.php:47 Stack trace: #0 /home/larry/web/test/public_html/report1.php(47): PDO->query('SELECT FILENAME...') #1 {main} thrown in /home/larry/web/test/public_html/report1.php on line 47 The Select statement doesn't error when run in mysql shell or phpmyadmin. Here's the result of show create table download: localhost/test/download/ http://localhost/phpmyadmin/tbl_sql.php?db=test&table=download&token=5739c407033be3e118287bc7a9041c2c Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available. Your SQL query has been executed successfully. show create table download download CREATE TABLE `download` ( `ID` int(5) NOT NULL AUTO_INCREMENT, `LOG_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `IP_ADDRESS` int(64) unsigned NOT NULL, `FILENAME` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL, `country` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL, `area` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL, `city` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `ID` (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1266 DEFAULT CHARSET=utf8 COLLATE=utf8_general_mysql500_ci Does anyone have an idea why this is happening?
Hi everyone, Happy New Year in advance! I have the following error occurring :- while ($row = $query_result->fetch_assoc()) { $result[] = $row; } Which is in this query :- public function DbGetAll($queryString) { $query_result = $this->db->query($queryString); $result = array(); while ($row = $query_result->fetch_assoc()) { $result[] = $row; } return $result; }
I'm guessing it's a problem with the sql query but I'm not sure how to fix? The error log also references this file :- So i got a table that looks somthing like this: File Name | Download | Suggested Catagory | Select Catagory | Approve -------------------------------------------------------------------------------------- test | Download | blah blah blah | Option menu | yes or no option menu test | Download | blah blah blah | Option menu | yes or no option menu test | Download | blah blah blah | Option menu | yes or no option menu what I want to do is in the file that processes this it only looks at the ones that have had the "approve column" submitted as a yes. Next it will to a mysql entry into verrified notes. Problem is with X amount of entries in that form I dont know how to look at only the ones that have said yes. Do I create a new form for each entry or put them all as one entry and after this what do I do next? Okay, so now I need help evolving my Log-In system... Up until now, the only place a user could log-in was on a given Article page if they wanted to add a comment to the Article. To accommodate that feature, I was setting the "Return To Page" only in my "article.php" script like this... Code: [Select] $_SESSION['returnToPage'] = $_SERVER['SCRIPT_NAME'] . '?title=' . $articleTitle; However, now I want to expand things. I'm growing increasingly confused about how to manage where to route people when they long-in?! 1.) Sometimes a user will Log-In and want to return where they were at (e.g. index.php, article1234.php) 2.) Sometimes a user might want to continue down a path (e.g. Checking Out, Registering for a Workshop, Sending a Message) Is there some kind of strategy to handle this? (nothing over complex, but there must be some Best Practices that work?! Debbie So I'm sitting at my desk scratching my head on how to do a task where I pull information form a database (that i know how to do) but then i need to see if two variables equal a string and if they do count out how many times that two variables equal there two string checks and out put the counted number ? this is what I have thought of but dose not to work because I cant figure out a way to code it? $dbPull = mysql_fetch_array($result) if( $dbPull['Foo'] == 'string1' && $bdPull['Bar'] == 'string2') this is were I get lost I'm looking for (how many times in the DB dose String2 show up in the array were the above, IF statement is true ) any ideas would be most appreciated I have just completed a modest way for Users to post Comments on Articles my website. However, the thought occurred to me today, that I haven't given Users the ability to Preview or Edit their comments after submittal. What is the best way to store info on a Comments Form so you can re-display it for Preview/Editing?? (I'm not really sure how the workflow would work for this?!) Do I capture the Comments Form Data and store it in a Session? Or in my Database? Or do something else? Security is always a concern of mine too!! Thanks, Debbie Dusting off my PHP skills after some time! How would I do this... Code: [Select] IF form was submitted THEN do some PHP stuff and do not show the form again ELSE display the form for the first time Is it as simple as wrapping my HTML inside an If-Then-Else? Debbie How do I make my constructor work when I don't pass in an argument. That is, it should efault to null. Code: [Select] class Something{ private $type=null; public function __construct($t){ $this->type = $t; } public function setSomething($t){ $this->type = $t; } public function getSomething(){ if (is_null($this->type)) { return "None for you!"; } else { return "Something is " . $this->type . "."; } } } TomTees I was wondering if there's any common method for user management. I'm not talking about basic stuff like DB management stuff I'm talking about registering new users with captcha, validating email addresses, password resets, etc. I can work all this stuff out by hand but it seems rather large and very repetitious so I was wondering if there's guides out there to develop this or a common script? |