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. Hey guys, So I have been looking around for a while, and I was wondering if I could read process memory (rpm) and write process memory (wpm) from my webserver to the client. Say I had a c++ 32 bit application and I wanted to read memory of the application and change it, is it possible to do this? Ideally it would be a server side language, also I had a look and the basic consensus is no, however is it possible to do something similar to mouse_event in php, js or another web server language. Sorry I am new! Thanks guys! I found this string shmop_read ( int $shmid , int $start , int $count ) which is reading a shared memory block. What is a shared memory block? Thanks!
  2. Hey guys: I have a database that is full of items. Each item lives in a box, with various accessories. I'm trying to loop through this DB to print out a label for each case that shows the amount of items that are in the case, along with the accessories that belong to it. I currently have a rather convoluted bit of code, that kind of works, but doesn't have the order that I want. My result is currently this: 4 X Generic lighting hanging clamp 4 X Generic lighting hanging clamp 4 X Generic lighting hanging clamp 4 X Generic lighting hanging clamp 4 X Generic lighting hanging clamp 2 X 25kg Safety Bond 2 X 25kg Safety Bond 2 X 25kg Safety Bond 2 X 25kg Safety Bond 2 X 25kg Safety Bond 2 X 16a to Powercon 2 X 16a to Powercon 2 X 16a to Powercon 2 X 16a to Powercon 2 X 16a to Powercon ********** 12 X Generic lighting hanging clamp 6 X 25kg Safety Bond ********** All the information is there, but due to the way that it loops through it's in the wrong order. I'd like it to be grouped so it looks like this so that it is grouped by box: 4 X Generic lighting hanging clamp 2 X 25kg Safety Bond 2 X 16a to Powercon 4 X Generic lighting hanging clamp 2 X 25kg Safety Bond 4 X Generic lighting hanging clamp 2 X 16a to Powercon 4 X Generic lighting hanging clamp 2 X 25kg Safety Bond 2 X 16a to Powercon 4 X Generic lighting hanging clamp 2 X 25kg Safety Bond 2 X 16a to Powercon ********** 12 X Generic lighting hanging clamp 6 X 25kg Safety Bond ********** Here is the code that I'm using. At the moment I'm just concentrating on the if ($item_type == '2') part, but have shown the whole lot so you can see what I'm doing. foreach ($distinct_path as $path) { $sql = "SELECT * FROM current_items WHERE path = '$path'"; $result = $con->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $item_name = $row['item_name']; $item_type = $row['item_type']; $item_qty = $row['qty']; $case_qty = $row['case_qty']; if ($item_type == '1') // THESE ARE MAIN ITEMS { $total_main_qty = $row['qty']; //main item QTY; $main_item_name = $item_name; } // This code will tell us number of full boxes, and number of extra lights left over $amtoffull = $total_main_qty/$case_qty; $amtoffull = floor($amtoffull); // we round down to the nearest whole number $total_left = $total_main_qty - ($case_qty * $amtoffull); if ($item_type == '2') // THESE ARE ACCESSORIES { $asc_qty = $row['qty']; //main item QTY; $asc_qty = $asc_qty/$total_main_qty; // THIS GIVES US THE TOTAL OF ONE Item $asc_qty = $asc_qty * $case_qty; // This is a full case amount //echo $asc_qty ." x ". $item_name ."</p>"; while ($i < $amtoffull) { echo $asc_qty ." X ". $item_name ."</p>"; ++$i; } } $i = 0; } echo "**********"; echo "<p>"; } I think I need to either shift the loops around so they work in a different order, or store everything into an array and then loop through that. Can any one help?
  3. Hey guys, I have a php array that looks like this: Array ( [opportunity_items] => Array ( [0] => Array ( [id] => 2783 [opportunity_id] => 92 [item_id] => [item_type] => [opportunity_item_type] => 0 [opportunity_item_type_name] => Group [name] => Strobes [transaction_type] => [transaction_type_name] => [accessory_inclusion_type] => [accessory_inclusion_type_name] => [accessory_mode] => The array goes on for ages, but I have only shown the bits I need. I want to create a new array that just contains the [id] key. I can get the first value by doing this: echo $array["opportunity_items"]["0"]["id"]; But I somehow I need to loop through this to get all of the rest of the values. Thanks, Andy
  4. Hi I am getting the above error on line highlighted In red below but cannot work out why. Any ideas? <?php session_start(); if(isset($_SESSION['usr_id'])!="") { header("Location: index.php"); } include_once 'dbconnect.php'; //check if form is submitted if (isset($_POST['login'])) { $email = mysqli_real_escape_string($con, $_POST['email']); $password = mysqli_real_escape_string($con, $_POST['password']); $result = mysqli_query($con, "SELECT * FROM users WHERE email = '" . $email. "' and password = '" . md5($password) . "'"); if ($row = mysqli_fetch_array($result)) { $_SESSION['usr_id'] = $row['id']; $_SESSION['usr_name'] = $row['name']; header("Location: index.php"); } else { $errormsg = "Incorrect Email or Password!!!"; } } ?> <!DOCTYPE html> <html> <head> <title>PHP Login Script</title> <meta content="width=device-width, initial-scale=1.0" name="viewport" > <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" /> </head> <body> <nav class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <!-- add header --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="index.php">Koding Made Simple</a> </div> <!-- menu items --> <div class="collapse navbar-collapse" id="navbar1"> <ul class="nav navbar-nav navbar-right"> <li class="active"><a href="login.php">Login</a></li> <li><a href="register.php">Sign Up</a></li> </ul> </div> </div> </nav> <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4 well"> <form role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform"> <fieldset> <legend>Login</legend> <div class="form-group"> <label for="name">Email</label> <input type="text" name="email" placeholder="Your Email" required class="form-control" /> </div> <div class="form-group"> <label for="name">Password</label> <input type="password" name="password" placeholder="Your Password" required class="form-control" /> </div> <div class="form-group"> <input type="submit" name="login" value="Login" class="btn btn-primary" /> </div> </fieldset> </form> <span class="text-danger"><?php if (isset($errormsg)) { echo $errormsg; } ?></span> </div> </div> <div class="row"> <div class="col-md-4 col-md-offset-4 text-center"> New User? <a href="register.php">Sign Up Here</a> </div> </div> </div> <script src="js/jquery-1.10.2.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html> Thank in advance Shane
  5. Hello everyone. Hope you will fine. i want to work on a project which will have three tables, i want to insert and fetch data from tables on webpage. on index page there will list of categories, when user click on anyone of category an other Page "Data Mini" will open, on "data mini" page there will 4 lines of each ROW Record and below it a button for READ MORE, when user click on Read More button, data of mentioned record will Open. so how to do it ? can anybody help ?
  6. Hi, I hope I am in the right place for some help. If not, I apologize I have just installed e-fiction on my website and I am having a little issue with some of the codes and where I need to go to modify things. This is a screenshot of the page and what I am trying to modify. What I want to do is make the banner CENTERED. This I thought was easy but whatever I do, it doesn't seem to work. I must be looking in the wrong place. Secondly, I want to move the menu bar - HOME - MEMBERS - SEARCH etc underneath the banner and that too to be centered. I am going to upload the files to Sendspace ( http://www.sendspace.com/file/mi0i6e), as the zip is too big to upload here and I am unsure which files need to be modified (that is where I am stuck) Thank you SO much, and I hope someone can help me. I am trying to learn all of this and it's all so confusing
  7. how can i limit the data (display only last 10 )that display in this while loop $name = $userdata[1]; $attendance = $zk->getAttendance(); sleep(1); while(list($idx, $attendancedata ) = each($attendance)): if ( $attendancedata[2] == 1 ) $status = 'Check Out'; else $status = 'Check In'; ?> <tr> <td><?php echo $idx ?></td> <td><?php echo $attendancedata[0] ?></td> <td><?php echo $name ?></td> <td><?php echo $attendancedata[1] ?></td> <td><?php echo $status ?></td> <td><?php echo date( "d-m-Y", strtotime( $attendancedata[3] ) ) ?></td> <td><?php echo date( "H:i:s", strtotime( $attendancedata[3] ) ) ?></td> </tr>
  8. Hi All, This is part of a PHP script that I am wanting to use to automate some daily data exports. The problem I am having, is adding a datestamp to my export file. The script itself works when executed in MySQL but not under PHP. Does anyone have any insight into how I can get this working? The error message I am currently getting is, and the part of php script I am running can be seen below. $sql1 = "SET @exportfile = CONCAT(SELECT 'FIELD_1' , 'FIELD_2' , .... UNION ALL SELECT * FROM mydatabasetable INTO OUTFILE 'E:/Data/exports/DailyExport/myexportfile" , DATE_FORMAT( NOW(), '%Y%m%d') , ".csv' FIELDS TERMINATED BY ',' ENCLOSED BY '''' LINES TERMINATED BY '\r\n' );"; $sql2 = "PREPARE processing FROM @exportfile;"; $sql3 = "EXECUTE processing;"; $sql4 = "DROP PREPARE processing;"; Any help here is greatly appreciated.
  9. RealPage in North Dallas is has 10 PHP Developer openings. All Direct Hire, No Remote. We are innovating from within and building our new generation of products, such as Rentjoy (http://www.realpage.com/realworld/ -watch Rentjoy Keynote – Dustin Gellman, our SVP Innovation Lab), ALL PHP. Ideally they would have Laravel experience but not required. RealPage is a growing SaaS and Cloud provider for the multifamily and rental industry with over 65 products. Job Desc: PHP Web Developer Job at RealPage, Inc. in Dallas/Fort Worth Area |https://www.linkedin.com/jobs/view/185472378 You can message me or you can apply online. Open to helping with relocation. John Laury john.laury@realpage.com
  10. I need to extract data from this, i need latd , latm and lats. How to search the array and return the values ? result i need $latd = 55 $latm = 56 $lats = 41.19 $url1 = "https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Broadwood_Stadium&rvsection=0"; $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $url1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_PROXYPORT, 3128); curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0); $response1 = curl_exec($ch1); curl_close($ch1); $response_a1 = json_decode($response1, true); $dist = $response_a1['query']['pages']; print_r($dist) ;
  11. It is possible to make it like the example below ? function funct1($number1, $number2) { $variable1 = $number1 + $number2 ; } function funct2($variable1 , $number3) { $variable2 = $variable1 / $number3 ; }
  12. At my CMS I want to give site moderators ability to associate any meta information to a page. For meta keywords and description I have different fields but all other stuff are inserted like raw html , like this: <meta name="Generator" content="SomeCMS" /> <meta name="robots" content="nofollow" /> <link rel="canonical" href="http://example.com/content/poisk-i-upravlenie-kontentom" /> This html will be echoed to the page. Mainly only meta tags and link(rel=canonical) will be here. And now I think I have to make sure there is no xss attack in this code. So I need to filter it before saving to database. HtmlPurifier or http://github.com/voku/anti-xss don't work with meta tags. So what would you advise me? To parse text with regexp for meta tags and then check every metatag found for any style or on attributes or http-equiv="refresh"(to deny malicious metatag)?
  13. his is my code for a simple catalog store (no cart and checkout), a listing page that will change the items depending on the category (or subcategory). This is my db structure: prod_id Primary bigint(20) AUTO_INCREMENT user_id int(11) cat_id int(11) subcat_id int(11) prod_titulo varchar(250) prod_descripcion varchar(250) The file that is currently listing all the products (store.php) has this script: $(document).ready(function(){ $('#listing_store').empty(); $.ajax({ url: 'store-app/db_query.php', type: 'GET', dataType: 'json', //data: , success: function(data){ for (var i = 0; i < data.length; i++) { var dataHtml = '' + '<div class="col-xs-6 col-md-4 column productbox">' + '<a href="detail.php#' + + data[i].id +'">' + '</a>' + '<div class="product-info">' + ' <div class="product-title"><a href="detalle_producto.php#' + + data[i].id +'">' + data[i].titulo + '</a></div>' + '<div class="product-price">' + '<div class="pull-right"><a href="detalle_producto.php#' + + data[i].id +'" class="btn btn-info btn-sm" role="button">Ver</a></div>' + '<div class="pricetext">$'+ data[i].precio + '</div></div>' + '</div>' + '</div>' $('#listing_store').append(dataHtml); } } }); }); As a result i have the product listed in the listing page. the anchor link for the products to the detail page (detail.php): <a href="detail.php#' + + data[i].id +'"></a> This is the script i have in the detail.php page: $(document).ready(function() { if(window.location.hash){ var id = window.location.hash.substring(1); $('#title').html('cargando...'); $('#desc').html('cargando...'); } LoadProduct(id); }); function LoadProduct(id){ $.ajax({ url: 'store-app/db_query.php', type: 'POST', dataType: 'json', data: { "q": id, }, }).done(function(aviso){ var id = aviso.id; $('#title').html(aviso.titulo); $('#desc').html(aviso.descripcion); }); } }); The product loads ok but the url is mysite/detail.php#1 -> prod_id Finally, the db query file (db_query.php): $sql = mysqli_query($dbc, "SELECT * FROM tienda_prod WHERE prod_activo ='1' ORDER BY prod_fechacreado DESC"); $results = array(); while($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){ $results[] = array( 'id' => $row["prod_id"], // or smth like $row["video_title"] for title 'user' => $row["user_id"], 'categoria' => $row["cat_id"], 'subcategoria' => $row["subcat_id"], 'titulo' => $row["prod_titulo"], 'descripcion' => $row["prod_descripcion"], ); } header('Content-Type: application/json'); if (isset($_REQUEST["q"])) { $busqueda = $_REQUEST["q"]; $clave = array_search( $busqueda , array_column($results, 'id') ); echo json_encode( $results[ $clave ] ); } else { echo json_encode( $results ); } What can i do to change product url's to be more friendly/clean: mystore.com/detail.php#1 to mystore.com/(category or subcategory name)/(product title + id) Ex. mystore.com/electric-guitars/fender-telecaster-1 Aclaration: I have other two tables in the db for subcategories and categorias, both with id and name, the product table has both category and subcategory id.
  14. So i've bought two themes but need to transplant one function to the other (both are very similar) and i'm trying to get my head around whats required and what does what... So apart from the basic CSS these are the related files i've found The main code <?php /** * Job Listing: Business Hours * * @since Listify 1.0.0 */ class Listify_Widget_Listing_Business_Hours extends Listify_Widget { public function __construct() { $this->widget_description = __( 'Display the business hours of the listing.', 'listify' ); $this->widget_id = 'listify_widget_panel_listing_business_hours'; $this->widget_name = __( 'Listify - Listing: Business Hours', 'listify' ); $this->settings = array( 'title' => array( 'type' => 'text', 'std' => '', 'label' => __( 'Title:', 'listify' ) ), 'icon' => array( 'type' => 'text', 'std' => 'ion-clock', 'label' => '<a href="http://ionicons.com/">' . __( 'Icon Class:', 'listify' ) . '</a>' ) ); parent::__construct(); } function widget( $args, $instance ) { global $job_manager; extract( $args ); $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); $icon = isset( $instance[ 'icon' ] ) ? $instance[ 'icon' ] : null; if ( $icon ) { if ( strpos( $icon, 'ion-' ) !== false ) { $before_title = sprintf( $before_title, $icon ); } else { $before_title = sprintf( $before_title, 'ion-' . $icon ); } } $hours = get_post()->_job_hours; if ( ! $hours ) { return; } global $wp_locale; $numericdays = listify_get_days_of_week(); foreach ( $numericdays as $key => $i ) { $day = $wp_locale->get_weekday( $i ); $start = isset( $hours[ $i ][ 'start' ] ) ? $hours[ $i ][ 'start' ] : false; $end = isset( $hours[ $i ][ 'end' ] ) ? $hours[ $i ][ 'end' ] : false; if ( ! ( $start && $end ) ) { continue; } $days[ $day ] = array( $start, $end ); } if ( empty( $days ) ) { return; } ob_start(); echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } do_action( 'listify_widget_job_listing_hours_before' ); ?> <?php foreach ( $days as $day => $hours ) : ?> <p class="business-hour" itemprop="openingHours" content="<?php echo $day; ?> <?php echo date_i18n( 'Ga', strtotime( $hours[0] ) ); ?>-<?php echo date( 'Ga', strtotime( $hours[1] ) ); ?>"> <span class="day"><?php echo $day ?></span> <span class="business-hour-time"> <?php if ( __( 'Closed', 'listify' ) == $hours[0] ) : ?> <?php _e( 'Closed', 'listify' ); ?> <?php else : ?> <span class="start"><?php echo $hours[0]; ?></span> – <span class="end"><?php echo $hours[1]; ?></span> <?php endif; ?> </span> </p> <?php endforeach; ?> <?php do_action( 'listify_widget_job_listing_hours_after' ); echo $after_widget; $content = ob_get_clean(); echo apply_filters( $this->widget_id, $content ); } } I guess it's calling this for the styling and formatting information for the table? <?php /** * */ global $wp_locale; if ( is_admin() ) { global $field; } $days = listify_get_days_of_week(); ?> <table> <tr> <th width="40%"> </th> <th align="left"><?php _e( 'Open', 'listify' ); ?></th> <th align="left"><?php _e( 'Close', 'listify' ); ?></th> </tr> <?php foreach ( $days as $key => $i ) : ?> <tr> <td align="left"><?php echo $wp_locale->get_weekday( $i ); ?></td> <td align="left" class="business-hour"><input type="text" class="timepicker" name="job_hours[<?php echo $i; ?>][start]" value="<?php echo isset( $field[ 'value' ][ $i ] ) && isset( $field[ 'value' ][ $i ][ 'start' ] ) ? $field[ 'value' ][ $i ][ 'start' ] : ''; ?>" class="regular-text" /></td> <td align="left" class="business-hour"><input type="text" class="timepicker" name="job_hours[<?php echo $i; ?>][end]" value="<?php echo isset( $field[ 'value' ][ $i ] ) && isset( $field[ 'value' ][ $i ][ 'end' ] ) ?$field[ 'value' ][ $i ][ 'end' ] : ''; ?>" class="regular-text" /></td> </tr> <?php endforeach; ?> </table> and lastly this... <?php class Listify_WP_Job_Manager_Business_Hours extends Listable_Integration { public function __construct() { $this->includes = array(); $this->integration = 'wp-job-manager'; parent::__construct(); } public function setup_actions() { add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); // save [front, back] add_action( 'job_manager_update_job_data', array( $this, 'job_manager_update_job_data' ), 10, 2 ); add_action( 'job_manager_save_job_listing', array( $this, 'job_manager_update_job_data' ), 10, 2 ); // add to frontend add_filter( 'submit_job_form_fields', array( $this, 'submit_job_form_fields' ) ); // custom input add_action( 'job_manager_input_business_hours', array( $this, 'job_manager_input_business_hours' ), 10, 2 ); // get current value add_filter( 'submit_job_form_fields_get_job_data', array( $this, 'get_job_data' ), 10, 2 ); // output in admin add_action( 'listify_writepanels_business_hours', array( $this, 'output_admin' ) ); } public function admin_enqueue_scripts() { global $pagenow; if ( ! ( in_array( $pagenow, array( 'post-new.php', 'post.php' )) && get_post_type() == 'job_listing' ) ) { return; } wp_enqueue_script( 'timepicker', Listable_Integration::get_url() . 'js/vendor/jquery.timepicker.min.js' ); wp_enqueue_style( 'timepicker', get_template_directory_uri() . '/css/vendor/jquery.timepicker.css' ); } public function submit_job_form_fields( $fields ) { $fields[ 'job' ][ 'job_hours' ] = array( 'label' => __( 'Hours of Operation', 'listify' ), 'type' => 'business-hours', 'required' => false, 'placeholder' => '', 'priority' => 4.9, 'default' => '' ); return $fields; } public function job_manager_update_job_data( $job_id, $values ) { if ( ! isset( $_POST[ 'job_hours' ] ) ) { return; } update_post_meta( $job_id, '_job_hours', stripslashes_deep( $_POST[ 'job_hours' ] ) ); } public function get_job_data( $fields, $job ) { $hours = get_post_meta( $job->ID, '_job_hours', true ); if ( ! $hours ) { return $fields; } $fields[ 'job' ][ 'job_hours' ][ 'value' ] = $hours; return $fields; } public function job_manager_input_business_hours( $key, $field ) { global $wp_locale, $post, $thepostid; $thepostid = $post->ID; ?> <div class="form-field" style="position: relative;"> <?php if ( ! is_admin() ) : ?> <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ) ; ?>:</label> <?php endif; ?> <?php global $field; if ( empty( $field[ 'value' ] ) ) { $field[ 'value' ] = get_post_meta( $thepostid, '_job_hours', true ); } get_job_manager_template( 'form-fields/business-hours-field.php' ); ?> <script> (function($) { $( '.timepicker' ).timepicker({ timeFormat: '<?php echo str_replace( '\\', '\\\\', get_option( 'time_format' ) ); ?>', noneOption: { label: '<?php _e( 'Closed', 'listify' ); ?>', value: '<?php _e( 'Closed', 'listify' ); ?>' } }); })(jQuery); </script> </div> <?php } public function output_admin() { do_action( 'job_manager_input_business_hours', '_job_hours', array( 'label' => __( 'Hours of Operation', 'listify' ), 'type' => 'business_hours', 'placeholder' => '', 'priority' => 99 ) ); } } Do i need to manually create the mysql tables or are they already being created? Is there more files i should be looking for? Absolutely clueless despite watching lots of tutorials on youtube, having a PHP & Mysql for dummies book beside me...
  15. I am using Laravel framework. I want to authenticate a user on all functions available in my code. I did not understood the constructor method quite right, and the docs were hard to follow as well. Assuming I have this code: public function __construct() { // Constructor for checking user's auth after a while. $this->middleware('auth'); if (!Auth::check()) { return redirect('auth/login'); } function something() { // How do I call it to work inside this function? } Thanks for helping.
  16. First code <?php include("conf.php"); $fixtures_data = mysqli_query($conn,"SELECT Location,Date,HomeTeam,AwayTeam FROM datagmaes"); if ($fixtures_data->num_rows > 0) { // output data of each row while($row = $fixtures_data->fetch_assoc()) { $team1 = $row["HomeTeam"]; $team2 = $row["AwayTeam"]; } } else { echo "0 results"; } ?> Second code <?php include("conf.php"); include("poi.php"); $home = mysqli_query($conn,"SELECT Teamdata1 FROM gamesdata WHERE Team='$team1'"); $row1 = $home->fetch_assoc(); $hometeam = number_format($row1['Teamdata1'],2); $away = mysqli_query($conn,"SELECT Teamdata2 FROM gamesdata WHERE Team='$team2'"); $row2 = $away->fetch_assoc(); $awayteam = number_format($row2['Teamdata2'],2); $calAll = array(); /////All calculations for($goals = 0 ; $goals <= 9 ; $goals++) { array_push($calAll, (poi($goals,$hometeam) * poi(0,$awayteam))*100, (poi($goals,$hometeam) * poi(1,$awayteam))*100, (poi($goals,$hometeam) * poi(2,$awayteam))*100, (poi($goals,$hometeam) * poi(3,$awayteam))*100, (poi($goals,$hometeam) * poi(4,$awayteam))*100, (poi($goals,$hometeam) * poi(5,$awayteam))*100, (poi($goals,$hometeam) * poi(6,$awayteam))*100, (poi($goals,$hometeam) * poi(7,$awayteam))*100, (poi($goals,$hometeam) * poi(8,$awayteam))*100, (poi($goals,$hometeam) * poi(9,$awayteam))*100 ); } $result1 = number_format(array_sum($calAll),2); echo $result1 . "\n"; ?> The first code return multiple items i need to apply the second code to every item in first code and then to save $result1 in mysql table. First code results if echo $team1," vs ",$team2; scgohometeam1 vs csgoawayteam1 scgohometeam2 vs csgoawayteam2 scgohometeam3 vs csgoawayteam3 scgohometeam4 vs csgoawayteam4 scgohometeam5 vs csgoawayteam5 scgohometeam6 vs csgoawayteam6 ... etc. Thes desired final echo after combinin the two codes Final code results if echo $team1," vs ",$team2," = ", $result1 ; scgohometeam1 vs csgoawayteam1 = 25 scgohometeam2 vs csgoawayteam2 = 45 scgohometeam3 vs csgoawayteam3 = 40 scgohometeam4 vs csgoawayteam4 = 30 scgohometeam5 vs csgoawayteam5 = 15 scgohometeam6 vs csgoawayteam6 = 23 ... etc.
  17. I have an html form that inserts a record into database. I also have a an html edit form that retrieves the data from the database. Normally everything works. But I just noticed that I have an issue if I use double quotes in the form field. It'll insert into the database fine. The problem arises when outputting the variable in the form field. If I echo it outside the form field, it'll show up fine with the double quotes. But inside the field, I only geta partial string. For eg. $variable_input = '5 3/4" Glitter Concealed Platform Pump'; The above will insert to the database. But if I retrieve it in the form field below, it'll return with one number only. <input type="text" name="title" value="5" /> Is there a way to fix the variable output of the wording that includes the double quotes?
  18. Hi I have been putting together a CMS system for users that have no idea how to use HMTL, at this time I have managed to build a basic CMS and now I am looking to extend the functionality of its use, right now the user can view the public pages with links, login to the Admin area to manage the subjects or pages and visibility of all and delete any of all or add an admin member, that's a nut shell to a ot of work already done; moving forwards I want to take away the need for any user ever needing to type any code, so if they wish to change the font colour, weight, type o back ground colour or image etc..... so how would anyone recommend working this, I was thinking maybe add buttons and selection boxes that save the correct data into a separate table and retrieve both and concatenate it back together
  19. <?php function factorial($number) { if ($number < 2) { return 1; } else { return ($number * factorial($number-1)); } } function poisson($occurrence,$chance) { $e = exp(1); $a = pow($e, (-1 * $chance)); $b = pow($chance,$occurrence); $c = factorial($occurrence); return $a * $b / $c; } $x = 2.5; $y = 1.5; $calAll = array(); for($z = 0 ; $z <= 9 ; $z++) { array_push($calAll, (poisson($z,$x) * poisson(0,$y))*100, (poisson($z,$x) * poisson(1,$y))*100, (poisson($z,$x) * poisson(2,$y))*100 ); } $value = max($calAll); $key = array_search($value, $calAll); print_r($calAll) . "\n"; echo "max =",$value , " key =",$key . "\n";; ?> it is possible to find $z and the number 0,1 or 2 from the max of the returned array ? I used excel to perform this action and i found that for max=8.5854557290941 the $z is 2 and number 1 how to achieve this in php ?
  20. Hi We had an online aptitude test written for us back in 2004/2005. A user registers on our site then can take a test that evaluates what type of learner they are. After they complete the test, we can send them a .pdf report. The front end of our site is a wordpress site, the testing center is written in php. Once a user registers, they get a link on our site that sends them out of wordpress to the PHP testing pages. Question: if we have 4-5 users sign up at once ( which isn't a problem in wordpress ), is there a way to allow for those users to take the aptitude test all at once. As of now, the "testing center" part of our site is only allowing 1 user at a time. Is this how PHP works? Is it the hosting server? We are hosted by Network Solutions. The test is around 120 questions long and 3 pages. Thanks in advance.
  21. Here's a line. I want to add 100 more of same lines and increment the page numbers as shown below. I know I can just manually add 100 lines but Is there a way to do this with PHP that would make it easy? Or is this more of a javascript thing? // original $page1 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=1">1</a>'; // new $page1 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=1">1</a>'; $page2 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=2">2</a>'; $page3 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=3">3</a>'; $page4 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=4">4</a>'; $page5 = '<a href="?type='. $type_id .'&name='. $get_type_3_name_slug .'&page=5">5</a>'; ...etc
  22. Below I have "Input" where it shows the original string. Basically I want to remove everything before " - ". I would like to know how can I get the "Output" results using PHP? Input $variable_1 = Lulu-free - Swimsuit swimwear red $variable_2 = Pap & Jones - Bard Mini Dress Output $variable_1 = Swimsuit swimwear red $Variable_2 = Bard Mini Dress
  23. I have this code: class DropzoneController extends Controller { public function __construct() { $this->middleware('auth'); if (!Auth::check()) { return redirect('auth/login'); } $this->user = Auth::user(); } public function index() { return view('dropzone_demo'); } public function uploadFiles() { $message="Profile Image Created"; $input = Input::all(); $rules = array( 'file' => 'image|max:3000', ); $validation = Validator::make($input, $rules); if ($validation->fails()) { return Response::make($validation->errors->first(), 400); } $destinationPath = 'uploads'; // upload path: public/uploads $extension = Input::file('file')->getClientOriginalExtension(); // getting file extension $fileName = rand(11111, 99999) . '.' . $extension; // renameing image $upload_success = Input::file('file')->move($destinationPath, $fileName); // uploading file to given path if ($upload_success) { return Response::json('success', 200); } else { return Response::json('error', 400); } // attaching the profile image to the authenticated user. $user->profileImage()->create([ 'filename' => $filename ]); Session::flash('new_profile_image', 'Profile Photo Updated!'); } public function authorize($ability, $arguments = Array) { // set to true instead of false return true; } } The error occurs for this line: public function authorize($ability, $arguments = Array) and it says: syntax error, unexpected ')', expecting '(' Not sure what that means. Anyone who can tell me what the issue is?
  24. So there are three major problems in my script securityi will do this by my self... so dont judge me for issues in this specific topic i just started this... upload dir won't work instead it drops the file in the main dir where the index lays... and names it with vid instead of putting it to the vid dir it cant upload videos somehow...i already changed the ini so that files in size of 1gb can be uploaded on to the server. there are no errors displayed: Code: Vidbase.php -> public function doupload ($UID,$TAGS,$VTITLE,$VDESCRIPTION,$VIDEO,$QUESTIONS,$GENRE) { $dir = "../../VID"; $fname = $VIDEO['name']; $ftmp = $VIDEO['tmp_name']; $ftype = $VIDEO['type']; $fsize = $VIDEO['size']; $ferr = $VIDEO['error']; $fname = preg_replace("/[^A-Z0-9._-]/i", "_", $fname); if (!$ftmp) { $fmsg = "Error: youve not choosen a file please do so in order t upload a file."; return $fmsg; } if ($ferr !== UPLOAD_ERR_OK) { $fmsg = "An error occurred"; return $fmsg; exit; } $i = 0; $parts = pathinfo($fname); while (file_exists($dir . $fname)) { $i++; $fname = $parts["filename"] . "-" . $i . "." . $parts["extension"]; } $success = move_uploaded_file($ftmp, $dir . $fname); if (!$success) { $fmsg = "upload failed"; return $fmsg; } chmod($dir . $fname, 0644); $fmsg = "upload complete"; return $fmsg; } upload.php <?php if (isset($_POST['submit'])) { $vid->doupload($userRow['userId'],null,"TITLE","DESCR",$_FILES['file'],null,"tech"); } ?> <form id="upload_form" enctype="multipart/form-data" method="post"> <input type="file" name="file" id="file1"><br> <button name="submit">UPLOAD</button> <progress id="progressBar" value="0" max="100" style="width:300px;"></progress> <h3 id="status"></h3> <p id="loaded_n_total"></p> </form> any sugestions ?
  25. Say below is my normal html href link. How would you turn this into a pretty URL using .htaccess? Also if I understand it correctly, this link will also have to be changed to match the pretty url. What would the new link look like? <a href="shop.php?type=45&name=belts">Belts</a>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.