Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I have my data array which i converted to json by splitting the keys using for each loop. Data: $data = Array ( [table6-ios-camt] => [table6-ios-iamt] => [table6-ios-samt] => [table6-ios-type] => [table6-isd-camt] => 0 [table6-isd-iamt] => 0 [table6-isd-samt] => 0 [table6-isd-type] => [table6-ios-csamt] => [table6-isd-csamt] => 0 [table6-other-camt] => [table6-other-iamt] => [table6-other-samt] => [table6-other-type] => [table6-tran1-camt] => 0 [table6-tran1-iamt] => [table6-tran1-samt] => 0 [table6-tran1-type] => [table6-tran2-camt] => 0 [table6-tran2-iamt] => [table6-tran2-samt] => 0 [table6-tran2-type] => [table6-itc_3b-csamt] => 0 [table6-dump_iog-camt] => [table6-dump_iog-iamt] => [table6-dump_iog-samt] => [table6-dump_iog-type] => [table6-dump_oth-camt] => 4386.09 [table6-dump_oth-iamt] => [table6-dump_oth-samt] => 4386.09 [table6-dump_oth-type] => [table6-itc_clmd-camt] => [table6-itc_clmd-iamt] => [table6-itc_clmd-samt] => [table6-itc_clmd-type] => [table6-total_10-camt] => 4386.09 [table6-total_10-iamt] => 0 [table6-total_10-samt] => 4386.09 [table6-total_10-type] => [table6-total_11-type] => [table6-total_8-csamt] => 0 [table6-total_9-csamt] => 0 [table6-dump_iog-csamt] => [table6-dump_isrc-camt] => [table6-dump_isrc-iamt] => [table6-dump_isrc-samt] => [table6-dump_isrc-type] => [table6-dump_oth-csamt] => [table6-iog_goods-camt] => [table6-iog_goods-iamt] => [table6-iog_goods-samt] => [table6-iog_goods-type] => Capital Goods [table6-itc_clmd-csamt] => [table6-total_10-csamt] => 0 [table6-dump_isrc-csamt] => [table6-iog_goods-csamt] => [table6-iog_inputs-camt] => [table6-iog_inputs-iamt] => [table6-iog_inputs-samt] => [table6-iog_inputs-type] => Input Services [table6-iog_inputs-csamt] => [table6-iog_services-camt] => [table6-iog_services-iamt] => [table6-iog_services-samt] => [table6-iog_services-type] => Input Services [table6-supp_non_rchrg_goods-camt] => [table6-supp_non_rchrg_goods-iamt] => [table6-supp_non_rchrg_goods-samt] => [table6-supp_non_rchrg_goods-type] => Capital Goods [table6-supp_rchrg_reg_goods-camt] => [table6-supp_rchrg_reg_goods-iamt] => [table6-supp_rchrg_reg_goods-samt] => [table6-supp_rchrg_reg_goods-type] => Capital Goods [table6-supp_non_rchrg_goods-csamt] => [table6-supp_non_rchrg_inputs-camt] => 4386.09 [table6-supp_non_rchrg_inputs-iamt] => [table6-supp_non_rchrg_inputs-samt] => 4386.09 [table6-supp_non_rchrg_inputs-type] => Inputs [table6-supp_rchrg_reg_goods-csamt] => [table6-supp_rchrg_reg_inputs-camt] => [table6-supp_rchrg_reg_inputs-iamt] => [table6-supp_rchrg_reg_inputs-samt] => [table6-supp_rchrg_reg_inputs-type] => Input Services [table6-supp_non_rchrg_inputs-csamt] => [table6-supp_rchrg_reg_inputs-csamt] => [table6-supp_rchrg_unreg_goods-camt] => [table6-supp_rchrg_unreg_goods-iamt] => [table6-supp_rchrg_unreg_goods-samt] => [table6-supp_rchrg_unreg_goods-type] => Capital Goods [table6-supp_non_rchrg_services-camt] => [table6-supp_non_rchrg_services-iamt] => [table6-supp_non_rchrg_services-samt] => [table6-supp_non_rchrg_services-type] => Input Services [table6-supp_rchrg_reg_services-camt] => [table6-supp_rchrg_reg_services-iamt] => [table6-supp_rchrg_reg_services-samt] => [table6-supp_rchrg_reg_services-type] => Input Services [table6-supp_rchrg_unreg_goods-csamt] => [table6-supp_rchrg_unreg_inputs-camt] => [table6-supp_rchrg_unreg_inputs-iamt] => [table6-supp_rchrg_unreg_inputs-samt] => [table6-supp_rchrg_unreg_inputs-type] => Input Services [table6-supp_non_rchrg_services-csamt] => [table6-supp_rchrg_reg_services-csamt] => [table6-supp_rchrg_unreg_inputs-csamt] => [table6-supp_rchrg_unreg_services-camt] => [table6-supp_rchrg_unreg_services-iamt] => [table6-supp_rchrg_unreg_services-samt] => [table6-supp_rchrg_unreg_services-type] => Input Services [table6-supp_rchrg_unreg_services-csamt] => ); json: { "table6":{ "ios":{ "camt":0, "iamt":0, "samt":0, "csamt":0 }, "isd":{ "camt":0, "iamt":0, "samt":0, "csamt":0 }, "other":{ "camt":0, "iamt":0, "samt":0, "csamt":0 }, "tran1":{ "camt":0, "iamt":0, "samt":0, "csamt":0 }, "tran2":{ "camt":0, "iamt":0, "samt":0, "csamt":0 }, "itc":{ "camt":0, "iamt":550, "samt":230, "csamt":680 }, "iog":[ { "itc_typ":"cg", "camt":0, "samt":0, "iamt":0, "csamt":0 }, { "itc_typ":"ip", "camt":0, "samt":0, "iamt":0, "csamt":0 }, { "itc_typ":"is", "camt":0, "samt":0, "iamt":0, "csamt":0 } ], "supp_non_rchrg":[ { "itc_typ":"cg", "camt":0, "samt":0, "iamt":0, "csamt":0 }, { "itc_typ":"ip", "camt":4386.09, "samt":4386.09, "iamt":0, "csamt":0 }, { "itc_typ":"is", "camt":0, "samt":0, "iamt":0, "csamt":0 } ], "supp_rchrg_reg":[ { "itc_typ":"cg", "camt":0, "samt":0, "iamt":0, "csamt":0 }, { "itc_typ":"ip", "camt":0, "samt":0, "iamt":0, "csamt":0 }, { "itc_typ":"is", "camt":0, "samt":0, "iamt":0, "csamt":0 } ], "supp_rchrg_unreg":[ { "itc_typ":"cg", "camt":0, "samt":0, "iamt":0, "csamt":0 }, { "itc_typ":"ip", "camt":0, "samt":0, "iamt":0, "csamt":0 }, { "itc_typ":"is", "camt":0, "samt":0, "iamt":0, "csamt":0 } ] } } The next thing i want to do is to unset the keys or entire inner objects of the json. Keeping in mind the following conditions: 1.If all the keys in the objects are 0 then the entire object will be removed (easy part). 2.If a key in the object has any value other than 0 , the object should not be removed and the key with "0" value should also be there. i've tried splitting value and using conditions to check for 0 or null values but the problem with that is it removes all keys that have 0 values thus failing condition 2 for the code. $vars = $data; $count = ""; $finalArray = array(); foreach ($vars as $keys => $values) { foreach ($values as $k => $v) { foreach ($v as $ke => $ve) { if ($keys == "table6") { $count = (array)$v; foreach ($count as $ck => $cv) { if ($cv != "0") { $flag = true; break; } } if($flag == false) { array_push($finalArray, $count); } } } } print_r($finalArray); die(); I expeced the output to contain the objects with key value pairs that does not contain 0 value but everything prints here.
  2. I have one restricted product, here how to do selected single product should be purchased alone? No other products are eligible to add add-to-cart if this product available in the add-to-cart, same if other products available in add-to-cart this product not eligible to add add-to-cart. How to achieve this in Magento?
  3. I am following the below module,https://www.webslesson.info/2018/04/...-ajax-php.htmlHow can i use without quantity [Product Name, Price, total, Action] i tried lot fail again and again. I am learning stage in PHP, any help pls welcome.
  4. Forgot Your Password Not working at the customer end, how to solve this error? Reset Password Email not sending to the customer mail account.
  5. How do I turn a checkbox on or off programatically? My form has several checkboxes that are grouped together and I want them to be turned on initially when the user first sees the form.I can do that very easily by just including "checked" in the HTML for the checkbox. But if the user turns off the checkbox before he presses Submit, I want to make sure I show the ones that are off as off when I redisplay the form as a result of errors in other fields, like textareas. How do I turn the checkbox off or on within my PHP code?
  6. <?php $a = array(-15, 3, 5, -1, -15); $b = array(1, 3, 5); function lowest_int ($c){ print_r(array_keys($c, min($c))); } print_r(lowest_int($a)); print_r(lowest_int($b)); ?> Hello guys the out of my code should be [0] => -15 [4] => -15 for the first array and [0] => 1 for the second array. However. this is my output: Array ( [0] => 1 [1] => 4 ) Array ( [0] => 0 ) Any ideas what am doing wrong? Thank you so much in advance!
  7. How to remove download option in audio control?
  8. I am using Payeezy Payment Gateway, how to integrate with my PHP page, actually the payment gateway for my customer form, i done with form using PHP, how can i integrate Payeezy Payment Gateway with my PHP form.
  9. When I send values to the foreach they are not recorded in the array. $x = $getProductID; $_SESSION['pColors'] = array(); if(isset($_POST['pColors'])) { foreach($_POST['pColors'] as $colorKey => $RColors) { $_SESSION['pColors'][$colorKey] = $RColors; } } var_dump($_SESSION['pColors']); Send date with AJAX: $('.addToCart').click(function(){ $.ajax({ url:""+realLink+"cart.php", method:"POST", data:{action:action,pColors:pColors}, success:function(data){ //alert(data); } }); });
  10. I have a form, details getting from customer and calculate the grand total, here how can i pass my grand total value to ccavenue payment gateway page and getting payment form customer? code : https://www.pastiebin.com/5cdbae859bb64
  11. I have folder with 100's images, how to find Height and width as Excel sheet?
  12. I have created a registration page to access my website. After the user registrate himself should appear an alert saying that the registration was OK and a redirect to main.php page... however for some reason if I create an insert statement the alert and the redirect don't appear... If I remove the insert the alert and the redirect works... why? This is part of the code of my 3 files: registration.php (ajax call) $('#submit').click(function() { var username2 = $('#uname2').val(); var password2 = $('#psw2').val(); $.ajax({ url: 'ajax/response.php', type: 'GET', data: {username2 : username2, password2: password2}, success: function(data) { if(data === 'correct') { alert("Username and Password have been created!"); //don' work with the insert location.replace("main.php"); //don' work with the insert } else { alert("Username or password are not correct... please register yourself!"); } } }); }); response.php (answer to ajax call) if(isset($_GET['username2']) && isset($_GET['password2'])) { $username2 = $_GET['username2']; $password2 = $_GET['password2']; if (checkUser($pdo, $username2) === true) { echo 'duplicate'; } else { insertUserPwd($pdo, $username2, $password2); //including this line the redirect and the alert doesn't work... the insert is OK echo 'correct'; } } data_access.php (the function works but doesn't permit alert and redirect to appear) function insertUserPwd(PDO $pdo, $usr, $pwd) { $data = [ 'id' => '', 'user' => $usr, 'password' => $pwd ]; $sql = "INSERT INTO users (id, user, password) VALUES (:id, :user, :password)"; $stmt= $pdo->prepare($sql); $stmt->execute($data); } Can someone help me to fix the code?
  13. I was wondering if there is a way to automatically get a user's timezone? I want to show certain information if the user's current date is less than the expiry date. It works fine if the user is in a default timezone but what if the user is in a different timezone? How I can I make sure I can get their correct current time? date_default_timezone_set('America/New_York'); $expiry_date = trim($row['expiry_date']); $current_date = date('Y-m-d H:i:s'); if($current_date < $expiry_date) { // show data } else { // don't show }
  14. I have a questions table and feedback table. I able to foreach the question header but not the feedback. My code as above: <?php $sql2 = "SELECT DISTINCT[question_id],[q_text] FROM [question]"; $ques = array(); $stmt2 = sqlsrv_query($conn, $sql2, $ques); while ($row = sqlsrv_fetch_array($stmt2, SQLSRV_FETCH_ASSOC)) { $ques[$row['question_id']] = $row['q_text']; } $sql = "SELECT [question_id], [Expr3],[Expr2] FROM [feedback] ORDER BY [Expr2] ASC"; $data = array(); $stmt = sqlsrv_query($conn, $sql); while (list($qid, $a, $eid) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { if (!isset($data[$qid][$eid])) { $data[$qid][$eid] = $newArray2; } $data[$qid][$eid][] = $a; } ?> <div class="container"> <?php // produce table header echo "<table border='1' id='table2excel'>\n"; echo "<tr><th>Employee ID</th>"; // loop over array of questions for the header foreach ($ques as $question) { echo "<th>$question</th>"; } echo "</tr>\n"; foreach ($data as $qid => $question) { foreach ($question as $question => $replies) { echo "<tr><td>$question</td>"; foreach (array_keys($ques) as $q_id) { echo "<td>"; echo $replies[$q_id]; echo "</td>"; } echo "</tr>\n"; echo "</tr>\n"; } } echo "</table>\n"; Questions Table: question_id q_text 1 Do you Like Red Color? 02A Do you Like Yellow Color? 02B Do you Like Blue Color? 3 Do you Like Green Color? 4 What color you like among them? 5 Do you Like Purple Color? 6 Do you Like Gold Color? 7 Do you Like Rose Gold Color? 8 Do you Like Black Color? 9 Do you Like Orange Color? The question 4, might be multiple answer. Feedback Table: question_id Expr2 Expr3 1 EMP1001 Yes 02A EMP1001 No 4 EMP1001 Red 4 EMP1001 Yellow 4 EMP1001 Blue 5 EMP1001 No 6 EMP1001 No 3 EMP1001 Yes 02B EMP1001 Yes 7 EMP1001 Yes 8 EMP1001 Yes 9 EMP1001 Yes 1 EMP1002 Yes 02A EMP1002 No 4 EMP1002 Red 5 EMP1002 No 6 EMP1002 Yes 3 EMP1002 Yes 02B EMP1002 Yes 7 EMP1002 No 8 EMP1002 9 EMP1002 Yes Result: Employee ID Do you Like Red Color? Do you Like Yellow Color? Do you Like Blue Color? Do you Like Green Color? What color you like among them? Do you Like Purple Color? Do you Like Gold Color? Do you Like Rose Gold Color? Do you Like Black Color? Do you Like Orange Color? EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 Expected Result: Employee ID Do you Like Red Color? Do you Like Yellow Color? Do you Like Blue Color? Do you Like Green Color? What color you like among them? Do you Like Purple Color? Do you Like Gold Color? Do you Like Rose Gold Color? Do you Like Black Color? Do you Like Orange Color? EMP1001 Yes No Yes Yes Red No No Yes Yes Yes EMP1001 Yes No Yes Yes Yellow No No Yes Yes Yes EMP1001 Yes No Yes Yes Blue No No Yes Yes Yes EMP1002 Yes No Yes Yes Red No Yes No Yes The question id no.4 will allow multiple choice to select, hence there will be multiple feedback for that particular question. foreach.txt
  15. i have this sql query result: +--------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+---------------+------+-----+---------+-------+ | Gender | enum('M','F') | YES | | NULL | | +--------+---------------+------+-----+---------+-------+ 1 row in set (0.00 sec) how can i loaad the enum type field into a select.I have tried this but it shows nothing $this->mGender = Cag::GetGender(); and in php script: echo $obj->mGender['Type'];
  16. Hello We have a testing site where users create a profile then take an aptitude test. Was working fine several months ago but we're trying to set up tests now and when the user enters their information and hits submit, we get these errors. (first it was the white screen, then I turned on the errors and received this) Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in ~/inc/connect.inc.php on line 11 Notice: Undefined variable: i_price in ~/profile-2.inc.php on line 97 Fatal error: Call to undefined function session_register() in ~/profile-2.inc.php on line 101 I'm assuming the Fatal Error is what's causing the profile not to be set up(and thus get the white screen). The code in profile-2 is: # Create new record: $now = time(); $password_name = random_password(PASS_LENGTH); $password_hash = bin2hex(mhash(MHASH_MD5, $password_name)); $i_qry2 = db_qry("INSERT INTO reports(createdate,passhash,fname,lname,age,gender,sport,loc,phone,address1,address2,city,state,zip,email,price) VALUES ($now,'$password_hash','$f_firstname','$f_lastname',$f_age,$f_gender,'$f_sport','$f_loc','$f_phone','$f_address1','$f_address2','$f_city','$f_state','$f_zip','$f_email','$i_price')") or die("Error: profile-2, SQL request error #2 ".mysql_error()); $i_sid = mysql_insert_id($sql_link); # Register SID in session: session_register('r_id'); <<<<this is line 101 $_SESSION['r_id'] = $i_sid; session_register('r_pass'); $_SESSION['r_pass'] = ''; session_register('r_ccode'); $_SESSION['r_ccode'] = stripslashes($f_ccode); Does anyone have a suggestion on what might be the problem and how I go about fixing it? Thanks in advance.
  17. Hello guys, I have a page named compare.php with two dropdown lists wich are populated with same values from a specific table. Now what i want to do is when a user is selecting one value from the first dropdown and another value from the secound dropdown to be redirected to a page lets say compare-items.php?id=1&id=2 and here in two different cols to get the values for the items, in the first col the values for the first item, and in the secound col the values from the sec item. How can i achive that? Thank you very much!
  18. i'm trying to make a notification tab work but do not seem to get it right. The dropdown is working fine but the ajax call to newfriends.php is not working right, when viewed with firebug there are no results to be seen in the dropdown.Quite confusing. (note the dropdown menu is located in header and can only be displayed if the session is initialised) here is the ajax used in jquery: function load_notifications(view=''){ $.ajax({ url: "notification/new_friends.php", method: "POST", data:{view:"view"}, dataType:"json", success: function(data){ $(".dropdown-menu").html(data.notification); if(data.unseen_notification>0){ $(".badge1").html(data.unseen_notification); } } }); //$(".dynamic-notification").load("notification/pm_n.php"); // $(".dynamic-notification-f").load("notification/new_friends.php"); }; load_notifications(); $(document).on("click",".count_friend", function(){ load_notifications('yes'); }); //loads every 2 seconds for chat setInterval(function(){load_notifications();},2000); here is the new_friends.php content: <?php include '../includes/dbconfig.inc.php'; if (isset($_POST['view'])) { if($_POST['view'] !=''){ $update="update friends set count='1' where friend_one=:session and count='0'"; $stmt=$conn->prepare($update); $stmt->bindValue(":session", $_SESSION['uname']); $stmt->execute(); } $sql123="select id from friends where friend_two=:sess_uname and count='0'"; $stmt123=$conn->prepare($sql123); $stmt123->bindValue(":sess_uname", $_SESSION['uname']); $stmt123->execute(); $request_count=$stmt123->fetchColumn(); //$count_friend=$stmt123->rowCount(); /*$sql_f_count="select *from user where user_id=:session_id and activated='1' limit 1"; $stmt_f_count=$conn->prepare($sql_f_count); $stmt_f_count->bindValue(":session_id", $_SESSION['id']); $stmt_f_count->execute(); $user_details=$stmt_f_count->fetchAll(); $friend_badge=$user_details[0]['friend_count_badge'];*/ require "notification/friend_request_notification.php"; // $new_friends="<span class='dropdown'><a href='#' data-placement='bottom' class='btn dropdown-toggle' data-toggle='dropdown' title='Friend Requests' data-html='true'><span class='count_friend' style=' height:33px; width:30px;'><span class='badge1 label label-pill'>".$count."</span><img src='img/logo/group-button-white.png' style='height:25px; width:27px;' alt='new_friends_alert'></span></a><ul class='dropdown-menu'></ul></span>"; //if($request_count[0]>0){ //$new_friends="<a href='#' data-placement='bottom' class='btn' data-trigger='focus' title='Friend Requests' data-toggle='popover' data-html='true' data-content='".$friend_requests."'><span class='count_friend' style=' height:33px; width:30px;'><img src='img/logo/group-button-white.png' style='height:25px; width:27px;' alt='new_friends_alert'></span><span class='badge'>".$friend_badge."</span></a>"; /*}else{ $new_friends="<a href='all_notifications.php'><img src='img/logo/group-button-black.png' style='height:25px; width:27px;' alt='new_friends_alert'></a>"; }*/ //echo $new_friends; //} $data=array( 'notification'=>$friend_requests, 'unseen_notification' =>$request_count[0][0] ); and the code for friend requests output: <?php //error_reporting(0); require_once 'includes/dbconfig.inc.php'; $sql = "select * from friends where friend_two=:session and accepted='0' order by friends_date_made asc"; $stmt = $conn->prepare($sql); $stmt->bindparam(":session", $_SESSION['uname']); $stmt->execute(); $numrows = $stmt->fetchAll(PDO::FETCH_ASSOC); $friend_requests=""; if ($numrows < 1) { $friend_requests = "You do not have any friend requests"; echo "$friend_requests"; exit(); } else { foreach ($numrows as $i=>$row1 ) { $reqid = $row1['friend_id']; $user1 = $row1['friend_one']; $datemade = $row1['friends_date_made']; $datemade1 = strftime("%B %d, %y", strtotime($datemade)); $sql = "SELECT * FROM user WHERE uname=:user1 LIMIT 1"; $stmt = $conn->prepare($sql); $stmt->bindparam(":user1", $user1); $stmt->execute(); $thumbrow = $stmt->fetchAll(PDO::FETCH_ASSOC); $user1avatar = $thumbrow[$i]['avatar']; $user1id=$thumbrow[$i]['user_id']; if ($user1avatar =="") { $user1pic = '<img src="img/avatardefault.png" height="50" style="float:left;" width="50" alt="'.$user1.'" class="user_pic">'; } else { $user1pic = '<img src="../user/user/'.$user1id.'/'.$user1avatar.'" height="50" style="float:left;" width="50" alt="'.$user1.'" class="user_pic">'; } $friend_requests .= '<li><div id="'.$reqid.'" float="right" class="friendrequests"> <a href="home.php?u='.$user1.'">'. $user1pic .'</a> <div class="user_info '.$reqid.'" id="'.$reqid.'"><small>' . $datemade1 . '</small> <a href="home.php?u='.$user1.'">'.$user1.'</a> is requesting your friendship<br /><br /> <button id="'.$reqid.'" name="'.$_SESSION['uname'].'" sess="'.$_SESSION['id'].'" class="accept_btn btn btn-warning">Accept</button><span class="show-spinner"></span> or <button id="'.$reqid.'" name="'.$_SESSION['uname'].'" sess="'.$_SESSION['id'].'" class="reject_btn btn btn-warning">Reject</button> </div> </div><hr></li>'; } }
  19. Hello Experts, I need help on a wordpress plugin "Easy Student Results". I installed this plugin for my ITI Institute results and when entered all institution trades, courses, students separated with trades and then started adding results on the basis of trades then this plugin doesn't show results of all trades students. It only shows results of firstly created trades students results. All other trades students results are showing unavailability error. So i need your help. https://wordpress.org/plugins/easy-student-results Thank you Manish Bajpai
  20. I have a database written in and stored on a server. The table I will be accessing is called dataRep and houses Rep Data. This data is user input via form submission. Upon coming to the website there is an option to "View Rep Information" by submitting the Rep's ID that was given. That Rep ID will be the auto increment repID from the table. Upon clicking the button, it opens a new window that should display the rep's data. It does not, however. Here is the [html] the user will see: <div class="pop_box"> <a class="rms-button" href="#popup1">Enter Rep Number Here</a> </div> <div id="popup1" class="overlay"> <div class="popup"> <a class="close" href="#">×</a> <div align="center"><br> <br> <p>Enter rep number in box below. Submission will open new window.</p> <form method="get" action="/data/repPrepare.php" target="_blank" > <input type="text" id="repSelect" name="repSelect" placeholder="Enter Rep Number Given Here" /> <button type="submit" class="newbutton">VIEW</button> </form> </div> </div> ...and here is the [php] I have tried, which I get the following error: [indent]"Could not get data: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[repSelect]' at line 1"[/indent] <?php $dbhost = 'mhhost'; $dbuser = 'myuser'; $dbpass = 'mypass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = 'SELECT * FROM dataRep WHERE repID = [repSelect]'; mysql_select_db('reviewmy_jos1'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "Rep ID :{$row['repID']} <br> ". "Rep NAME : {$row['repName']} <br> ". "Rep Bio : {$row['repBio']} <br> ". "Rep Certs : {$row['repCerts']} <br> ". "--------------------------------<br>"; } echo "Fetched data successfully\n"; mysql_close($conn); ?> I am truly stuck and have been dealing with this issue for two weeks. I would appreciate any assistance that can be provided. I just need the [php] to pull the data tied the repID that the user puts in the box. When I started this I assumed it would be rather easy. I guess that's what I get for assuming. Either way, I'm missing something here. Is there a possibility that this can not be done? Like, I should be using AJAX instead?
  21. I'm in the middle of producing a calories tracker. My users can set weight loss goals and then use the exercise calorie calculator to find out how many calories they've lost from particular exercises. I've produced a progress bar to show users their progress, however the progress bar does this for all of the users goals combined, not the most recent goal set. How could I set my progress bar to focus on just the most recent goal set by the user? This is what I have so far <?php $con=mysqli_connect("localhost","root","password","registration"); if (mysqli_connect_errno()) { die("Failed to connect to MySQL: " . mysqli_connect_error()); } $bar_length = 500; $bar_height = 40; $sql = "SELECT SUM(calories) as calories , CASE g.weightunit WHEN 'lbs' THEN 3500 ELSE 7700 END * weightlost as target_calories FROM goal g INNER JOIN tracklog t USING (userid) WHERE userid = ?"; $stmt = $con->prepare($sql); $stmt->bind_param('i', $_SESSION['userid']); $stmt->execute(); $stmt->bind_result($calories, $target); $res = $stmt->fetch(); function progress_bar($width, $height, $calories, $target) { $bar = "<p style='padding-left: 30px'>"."<svg width='$width' height='$height' align='center' view_box='0 0 $width $height'>\n <rect x='0' y='0' width='$width' height='$height' align='right' fill='#CCC' />\n"; // calc width of bar for calories already burned if ($target==0) { $target = 1; } if ($calories > 0) { $cal_width = $calories * $width / $target; $bar .= "<rect x='0' y='0' align='center' width='$cal_width' height='$height' stroke='#ccc' fill='#55d5e7' />\n"; } else { $bar .= "<text x='5' y='16' align='center' font-size='9pt'>No data for user</text>\n"; } $bar .= "</svg>\n"; return $bar; } mysqli_close($con); ?> <p align="center" class="font-3" style="font-size: 16px"><br><br >Calories burned to date : <?=$calories?><br> Target calories : <?=$target?><br> <?= progress_bar($bar_length, $bar_height, $calories, $target) ?>
  22. If anyone could help, I'm not getting an error message and I've tried changing the code around a few times and outputting errors. The database does not update and i'm getting no error message output on submit, I assume i'm missing something? <?php session_start(); include_once 'dbconnect.php'; if (!isset($_SESSION['userSession'])) { header("Location: index.php"); } $query = $DBcon->query("SELECT * FROM tbl_users WHERE user_id=".$_SESSION['userSession']); $userRow=$query->fetch_array(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome - <?php echo $userRow['email']; ?></title> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" media="screen"> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <?php include_once 'header.php'; ?> <html> <head></head> <body> <h1>Send Message:</h1> <form action='message.php' method='POST'> <table> <tbody> <tr> <td>To: </td><td><input type='text' name='to' /></td> </tr> <tr> <td>From: </td><td><input type='text' name='from' /></td> </tr> <tr> <td>Message: </td><td><input type='text' name='message' /></td> </tr> <tr> <td></td><td><input type='submit' value='Create Task' name='sendMessage' /></td> </tr> </tbody> </table> </form> </body> </html> <?php if (isSet($_POST['sendMessage'])) { if (isSet($_POST['to']) && $_POST['to'] != '' && isSet($_POST['from']) && $_POST['from'] != '' && isSet($_POST['message']) && $_POST['message'] != '') { $to = $_POST['to']; $from = $userRow['email']; $message = $_POST['message']; $q = "INSERT INTO tbl_messages(id,message,to,from) VALUES('', '$message', '$to', '$from')"; if ($DBcon->query($q)) { $msg = "<div class='alert alert-success'> <span class='glyphicon glyphicon-info-sign'></span> Message Sent ! </div>"; }else { $msg = "<div class='alert alert-danger'> <span class='glyphicon glyphicon-info-sign'></span> Message not Sent! ! </div>"; } } } $DBcon->close();?> <?php php include_once 'footer.php'; ?> </html>
  23. Say I have this array. $block_io->get_current_price(array()); That array will give me this output. { "status" : "success", "data" : { "network" : "BTC", "prices" : [ { "price" : "1500.01", "price_base" : "AUD", "exchange" : "coinspot", "time" : 1488955012 }, { How can I convert the above output into individual variables? For eg. $status = 'success'; $network = 'BTC'; $price = '1500.01'; ...etc
  24. Hi, i have problem with login script. Problem is that i cant login using my username and password. Password i entered in database was with password_hash('admin', PASSWORD_DEFAULT); Here is a code <?php include 'config.php'; if (isset($_SESSION['laa'])) { die('U already logged in. <a href="index.php">Home</a>'); } if (isset($_POST['login'])) { if (isset($_POST['username']) && isset($_POST['password'])) { $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); if (empty($username) || empty($password)) { $error = 'Please enter username and password.'; } else { //$password = password_verify($password, PASSWORD_DEFAULT); $stmt = $dbh->prepare("SELECT * FROM administrator WHERE korisnicko_ime = :username AND lozinka = :password"); $stmt->bindParam(':username', $username); $stmt->bindParam(':password', $password); $stmt->execute(); $p = $stmt->fetch(); //password_verify($password, $data['password'])) if ($p['username'] == $username || $p['password'] == $password) { $_SESSION['laa'] = $username; header('Location: index.php'); exit(); } else { $error = 'Invalid username or password.'; } } } else { $error = 'Please enter username and password.'; } } ?> <center> <div style="display:block; margin-top: 10%;"> <p><?php if(!empty($error)) { echo $error; } ?></p> <form action="login.php" method="post"> <p>Username : <input type="text" name="username"></p> <p>Password : <input type="password" name="password"></p> <p><input type="submit" name="login" value="Login"></p> </form> </div> </center>
  25. I stumbled upon a video in develop php, that uses php to create a dynamic xml file. I tried to use their code, and modify to my needs but I wasn't able to. I need a php file that creates an xml with all the subfolders in a folder and the images inside those subfolders. Can someone please help me get this working? Thanks. This is what I have tried so far: http://www.developphp.com/video/PHP/Image-Gallery-PHP-Loop-Files-Dynamic-XML-Tutorial <?php header("Content-Type: text/xml"); // set the content type to xml // Initialize the xmlOutput variable $xmlBody = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $dir = "../images/"; // Specify Directory where images are $xmlBody .= "<XML>"; // Start XMLBody output // open specified directory using opendir() the function $dirHandle = opendir($dir); // Create incremental counter variable if needed $i = 0; $root = '../images'; $iter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied" ); $paths = array($root); foreach ($iter as $path => $dir) { if ($dir->isDir()) { $paths[] = $path; if(!is_dir($file) && strpos($file, '.jpg')){ $i++; // increment $i by one each pass in the loop $xmlBody .= <'$paths[$iter]'>' '<'$paths[$iter]'> <picNum>' . $i . '</picNum> <picURL>' . $dir . '' . $file . '</picURL> </Picture>'; } // close the if statement } } while ($file = readdir($dirHandle)) { // if file is not a folder and if file name contains the string .jpg if(!is_dir($file) && strpos($file, '.jpg')){ $i++; // increment $i by one each pass in the loop } // close the if statement } // End while loop closedir($dirHandle); // close the open directory $xmlBody .= "</XML>"; echo $xmlBody; // output the gallery data as XML file for flash ?>
×
×
  • 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.