Jump to content

Search the Community

Showing results for tags 'query'.

  • 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 a pdo prepared statement that fetches records from mysql database. The records show up on the page. However if there are no records on a page, I get this error message. "QLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10' at line 4" Here is my statement $getCategoryId = $_GET['id']; $limit = 10; $offset = ($page - 1) * $limit; $statement = $db->prepare("SELECT records.*, categories.* FROM records LEFT JOIN categories ON records.category_id = categories.category_id WHERE records.category_id = :category_id ORDER BY record_id DESC LIMIT {$limit} OFFSET ".$offset); $statement->bindParam('category_id', $getCategoryId); $statement->execute(); $results = $statement->fetchAll(PDO::FETCH_ASSOC); If I remove try and catch block, it'll tell me exactly which line is giving the issue. So from the above code, the error has to do with "$statement->execute();". This is where the error occurs. As far as I know, the above pdo statement is correct. Can you tell me if something is wrong with it?
  2. I'm making statistic for 5 tables. I have made the example with one client data. loan: payment_schedule: payment_schedule_row payment_schedule_cover: payment_schedlue_delay: And the query is: SELECT period, loan_sum, covers, delay FROM (SELECT MAX(EXTRACT(YEAR_MONTH FROM psc.date)) AS period, (SELECT SUM(psr2.payment) FROM payment_schedule_row AS psr2 WHERE psr.payment_schedule_id = psr2.payment_schedule_id) AS loan_sum, (SELECT SUM(psc2.sum) FROM payment_schedule_cover AS psc2 WHERE psc.payment_schedule_id = psc2.payment_schedule_id) AS covers, (SELECT SUM(psd2.delay) FROM payment_schedule_delay AS psd2 WHERE psr.id = psd2.payment_schedule_row_id) AS delay FROM loan INNER JOIN payment_schedule AS ps ON ps.loan_id = loan.id INNER JOIN payment_schedule_row AS psr ON psr.payment_schedule_id = ps.id INNER JOIN payment_schedule_cover AS psc ON psc.payment_schedule_id = ps.id WHERE loan.status = 'payed' GROUP BY ps.id) AS sum_by_id GROUP BY period Sqlfiddle link: http://sqlfiddle.com/#!2/21585/2/0 Result for the query: period | loan_sum | covers | delay --------------------------------------- 201407 | 384 | 422 | 0.07 Everything is right except the delay. It should be 0.11 (0.07 + 0.03 + 0.01) So I have been trying to find the error from the query for days now. Maybe someone can tell me what I'm doing wrong.
  3. Working on a website directory that includes ratings for listed companies. Trying to obtain information from database that would put some companies in a higher category than others. Or at least, I believe that is the approach I should be taking. There are a few tricky issues. 1. Ratings are their own custom posts but are attached to company pages (parents) 2. Rating values I need to obtain are meta keys (1. total number of ratings & 2. rating average of EACH) 3. Ratings are based on four criteria which are summed and averaged for each rating submitted. As a result, values are rarely single digits such as 4 or 5 but include decimals rounded to 1 place (e.g. 4.8 or 3.5) Additional info: Ratings are based on 5-star system (out of 5) Higher category would be business that achieved at least 10 ratings of 4 or more Any help appreciated.
  4. hi im trying to use query to select from a table where the price is between to values that the user has to input such as min of 3 and max of 8 and return all the fields from the database where it is true im unsure how to do this but this is what i have so far $res = pg_query ($conn, "SELECT ref,artist,composer,genre,title,album,label,price,description FROM music WHERE price = < && > "); echo "<table border='1'>"; echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>";
  5. Hi there, I want to pass a input variable from login_success.php which will be sent to sqlprocess.php as the variable 'SQLinput'; sqlprocess.php $link = mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $query = $_REQUEST['SQLinput']; //You don't need a ; like you do in SQL $result = mysql_query($query); $numfields = mysql_num_fields($result); login_sucess.php <form action="" method="post" <label> <span>SQL Input :</span> <input type ="text" id="message" name="SQLinput" placeholder="Input SQL"></textarea> </label> <label> <span>SQL Output :</span> <output id="text" id="SQLoutput" ></input> <script type="text/javascript" charset="utf-8"> // handles the click event for link 1, sends the query function getOutput() { getRequest( 'sqlprocess.php', // URL for the PHP file drawOutput, // handle successful request drawError // handle error ); return false; } // handles drawing an error message function drawError () { var container = document.getElementById('output'); container.innerHTML = 'Bummer: there was an error!'; } // handles the response, adds the html function drawOutput(responseText) { var container = document.getElementById('output'); container.innerHTML = responseText; } // helper function for cross-browser request object function getRequest(url, success, error) { var req = false; try{ // most browsers req = new XMLHttpRequest(); } catch (e){ // IE try{ req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { // try an older version try{ req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ return false; } } } if (!req) return false; if (typeof success != 'function') success = function () {}; if (typeof error!= 'function') error = function () {}; req.onreadystatechange = function(){ if(req .readyState == 4){ return req.status === 200 ? success(req.responseText) : error(req.status) ; } } req.open("GET", url, true); req.send(null); return req; } </script> <a href="#" onclick="return getOutput();"><button type="submit" id="search_btn" value="Submit">Submit</button> </a> <div id="output">waiting for action</div> Prior to the JS code - I was able to peform this action - however the JS code enables me to post the query onto the same page. I would like essentially like to query the database through an input box and output the same result on the same page. Thanks!
  6. Hi there everyone! I've got a problem combining two queries. The situation is this. I've got a list of links and I want to allow the user to get a result list of all, only unread, all in a particular category and then only unread in a particular category. My query for all: /* No filtering and no unread */ $q_urls = "SELECT * FROM shortenified_urls WHERE is_social = '1' AND active = '1' ORDER BY date_added DESC"; My query for in a particular category: /* All links in a particular category */ $q_urls = " SELECT * FROM shortenified_urls WHERE shortenified_urls.primary_cat = $vu_cat_view OR EXISTS ( SELECT link_id FROM linkcats WHERE link_id = shortenified_urls.id AND cat_id = $vu_cat_view ) AND shortenified_urls.is_social = '1' AND shortenified_urls.active = '1' ORDER BY date_added DESC" ; My query for Unread in all cats: /* Unread only for all categories */ $q_urls = "SELECT * FROM shortenified_urls WHERE shortenified_urls.date_added > $vu_mark_as_read AND NOT EXISTS ( SELECT lid FROM linkviews WHERE lid = shortenified_urls.id AND uid = $viewing_user_id ) AND shortenified_urls.is_social = '1' AND shortenified_urls.active = '1' ORDER BY date_added DESC" ; These seem to be working well. It's the next one that isn't working for me. I tried to combine the "All in a particular category" and "Unread in all categories" using the two above as starting points. The result, however, seems to be that I'm getting all in a particular category. It seems to be ignoring the unread status. /* Unread links in a particular category */ $q_urls = " SELECT * FROM shortenified_urls WHERE shortenified_urls.primary_cat = $vu_cat_view AND shortenified_urls.date_added > $vu_mark_as_read OR EXISTS ( SELECT link_id FROM linkcats WHERE link_id = shortenified_urls.id AND cat_id = $vu_cat_view ) AND NOT EXISTS ( SELECT lid FROM linkviews WHERE lid = shortenified_urls.id AND uid = $viewing_user_id ) AND shortenified_urls.is_social = '1' AND shortenified_urls.active = '1' ORDER BY date_added DESC" ; I'm not smart enough to know why it's not working, but it seems to me like I need to somehow bracket the first two parts containing the category retrieval to make this work right. The only problem is I don't know how to do that. Any help on how to get this to work would be greatly appreciated!
  7. Given the below 3 database tables I am trying to construct a SQL query that will give me the following result: customer_favourites.cust_id customer_favourites.prod_id OR product.id product.code product.product_name product.hidden product_ section.section_id (MUST BE ONLY THE ROW WITH THE LOWEST SECTION ID, I.E. ROW ID #44108) product_ section.catpage (MUST BE ONLY THE ROW WITH THE LOWEST SECTION ID, I.E. ROW ID #44108) product_ section.relative_order (MUST BE ONLY THE ROW WITH THE LOWEST SECTION ID, I.E. ROW ID #44108) I currently have.... SELECT customer_favourites.cust_id, customer_favourites.prod_id, product.code, product.product_name, product.hidden, product_section.section_id, product_section.relative_order, product_section.catpage FROM customer _favourites INNER JOIN product ON customer_favourites.prod_id = product.id INNER JOIN product_section ON product_section.product_code = product.code WHERE `cust_id` = '17' AND `hidden` = '0' GROUP BY `code` ORDER BY `section_id` ASC, `relative_order` ASC, `catpage` ASC LIMIT 0,30 This gives me what I want but only sometimes, at other times it randomly selects any row from the product_section table. I was hoping that by having the row I want as the last row (most recent added) in the product_section table then it would select that row by default but it is not consistent. Somehow, I need to be able to specify which row to return in the product_section table, it needs to be the row with the lowest section_id value or it should by the last row (most recent). Pulling my hair out so any help is gratefully received. customer_favourites id cust_id prod_id 70 4 469 product id code product_name hidden 469 ABC123 My Product 0 product_section id section_id catpage product_code relative_order recommended 44105 19 232 ABC123 260 1 44106 3 125 ABC123 87 1 44107 2 98 ABC123 128 1 44108 1 156 ABC123 58 0
  8. I've been baffled by this for 2 days now and cannot figure it out after exhaustive searches. I'd like to think I'm doing this correctly, but cannot get it to work. I'm trying to use a variable within a query WHERE statement, and it shows 0 results. If I directly hardcode the text instead of using the variable, it works. The variable is pulling from a $_GET, and if I echo that variable, it is showing the correct text. Here's my code: $Domain = $_GET['Domain']; $result = mysql_query(SELECT Code, Title, Domain, Status FROM tablename WHERE Domain="$Domain" ORDER BY Code'); If I swap out "$Domain" for direct text, like "ABC", it works. I have tried swapping out the quotes and single quotes throughout the statement, removing the quotes around $Domain, concatenating the statement separately....all yield erros or the same result. And as stated, if I echo $Domain, it shows "ABC" (or whatever it's supposed to show), so i know it's pulling correctly from the $_GET. Anyone know what I'm doing wrong?
  9. I hope this is the right section of the forum for sql query help. I have three different tables in my phpmyadmin database for my website (Topics, Message, MessageReply). Users will have the ability to post messages within a topic and also respond to messages posted within each topic. I am now stuck trying to write a query that will display all of the topics created in one column and all Messages + Message Replies to those topics in a 2nd column. Please help. thanks,
  10. Hello guys, i'm currently building my own cms, a personal project, and now im stucked on an error "Call to a member function query() on a non-object in.. please help after creating this function.. I know the db connection and everything else worked out because i have a similar function that works just without the switch or the numrow if statement. protected function _pageStatus($option, $id){ //check if page exists, if it does return the status, or return 404 switch($option){ case 'alpha' : $sql = "SELECT status FROM pages WHERE nick = '$id'"; break; case 'num' : $sql = "SELECT status FROM pages WHERE id = '$id'"; break; } if($result = $this->_db->query($sql)){ //<--- THE ERROR WAS ON THIS LINE. if($result->num_rows > 0){ while ($status = $result->fetch_object()) { return $status; } return $status; $result->close(); } else { return 404; } } }
  11. Hello! I have a php page which shows a list of customers displayed in an html table format, The first column in the table contains a link for the user to select the row which then navigates to another php page, which is the customer order page. On this page, I want to get certain information based on the name of the customer to prepopulate the customer fields on this form, so I have some php code near the top of the page, as per attached document. I have checked to ensure that the $_GET['business_name'] contains a value. The query runs fine in myssql and returns only one record when I provide a value for the business_name, however when I run the code in php, the $result variable shows 'Resource id ='7' type='mySQL result'. I am a total newbie on PHP/MySQL and inherited this application. I have tried to find solutions on line through various forums, but no luck. Perhaps I am not asking/looking for the right question. Anyway, any assistance would be greatly appreciated. customer_order_php.php
  12. Hello. I' have a Table in MySQL That stores data (name/email/time) of when a person last run X script. I'm trying to pull that information for each user unique to their account to display so they know that they've already ran that script today How it works. Run script > Create's Row storing the data > MySQL Events deletes row after 24 hours. My code to display notification if they have already ran it; $sql = 'SELECT a.name, a.time FROM timecheck a, users b WHERE a.name = b.name'; mysql_select_db('My_DB'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "Account: {$row['name']} <br> ". "Last Time Run: {$row['time']} GMT -1<br> "; } echo "It seems you have done this already today!"; ?> Now my problem is. It's displaying every row to every user. I want it to only show the user their row... What I've tried. Creating a session variable "$sessionID" $sql = 'SELECT a.name, a.time FROM timecheck a, users b WHERE a.name = b.name AND a.name=$sessionID"'; But I'm not getting any lucky. All help is appreciated, thank you in advance.
  13. Hi, When I run an UPDATE query in my PHP code, nothing happends, no errors or anything. The weardest thing is, is that if I echo the query, it's the correct output. Any other queries that come after them are still executed. This is my query code: mysql_query("UPDATE users SET cash='".clean_string($info["cash"]-$_POST["bet"])."' WHERE login='".$info["login"]."'") or die(mysql_error()); mysql_query("UPDATE objecten SET bank='".clean_string($object["bank"]+$_POST["bet"])."' WHERE type='4' AND land='".$info["land"]."'") or die(mysql_error()); Thanks in advance, iRoot121.
  14. Hi guys, I had a question about how to do a safe query. For example, I've a query like SELECT * FROM users WHERE login='".$_GET["x"]."' Do I need to do more then just adding mysql_real_escape_string(), or is that one just enough? And how goes it for the INSERT, UPDATE, DELETE statement? And do you need to parse the output from a database before displaying it? Thanks in advance,
  15. I have the following code: <?php require_once("../db_settings.php"); require_once("../classes/dbHandler.class.php"); require_once("../classes/helpers.class.php"); $db = new DBConnection(); $fetchItems = new dbHandler($db, 'exp_weblog_data'); $return_arr = array(); if (isset($_GET["term"])) { $param = htmlspecialchars($_GET["term"]); $items = $fetchItems->getResultsByTerm($param, 'field_id_5', 10); /* Toss back results as json encoded array. */ echo json_encode($items); } else if(isset($_GET['debug'])) { $param = 0; $items = $fetchItems->getResultsByTerm($param, 'field_id_5', 10); $printArry = new helpers(); $printArry->printArray($items); } It basically pulls information from table "exp_weblog_data" and column "field_id_5". I need it however, to pull relevant information from another table called "exp_weblog_titles" and the column "title". If anyone could help me on this matter I would really appreciate it
  16. Hello all, I have created a script that queries my MySQL database and gets a certain row, then echoes out: if(!$result = $db->query($sql)){ die('There was an error running the query [' . $db->error . ']'); } while($row = mysqli_fetch_array($result)) { echo "<li><a href=\"#\">"; echo $row['col_5']; echo "</li>"; } I would like to check to see if each of the row outputs has a string that is more than 13 characters, and if so, strip it down to 13 and add "..." to the end of the string. I did some research and added a line of code, but it still outputs the long string. Any ideas on where I went wrong? if(!$result = $db->query($sql)){ die('There was an error running the query [' . $db->error . ']'); } while($row = mysqli_fetch_array($result)) { $row = (strlen($row) > 13) ? substr($row,0,10).'...' : $row; // ADDED THIS LINE echo "<li><a href=\"#\">"; echo $row['col_5']; echo "</li>"; }
  17. Hey guys, I'm trying to limit my query to 5 results, but TOP is not working and LIMIT obviously does not work (I usually work with MySQL). Here is my query: $query = "SELECT PERSON.PERSON_ID, PERSON.LAST_NAME, PERSON.FIRST_NAME FROM PERSON where PERSON.LAST_NAME like '%$q%' or PERSON.FIRST_NAME like '%$q%' order by PERSON.LAST_NAME"; Can someone please point me in the right direction for limiting the query to 5 results? Thank you! ~ Sarah
  18. Hi Guys I have written this function which basically finds all assets that have a certain document associated with them in a certain location. It works great however I need the opposite. I need all the assets that don't have this document but i cant get my head around the query can anyone help me please? function GetUploadedDocsNoAsset($doctype,$archive, $location){ $colname_DocUp = "-1";if (isset($doctype)) { $colname_DocUp = $doctype;} $colname_Archive = "-1";if (isset($archive)) { $colname_Archive = $archive;}$colname_Location = "-1";if (isset($location)) { $colname_Location = $location;} $query_DocUp = sprintf("SELECT idAssetDocStand FROM AssetDocStand INNER JOINAsset ON AssetDocStand.idAsset = Asset.idAssetWHERE AssetDocStand.idDocumentStandards = %s AND AssetDocStand.Archive=%s AND Asset.idLocation = %s", GetSQLValueString($colname_DocUp, "int"), GetSQLValueString($colname_Archive, "text"), GetSQLValueString($colname_Location, "int"));$DocUp = mysql_query($query_DocUp);$totalRows_DocUp = mysql_num_rows($DocUp);return $totalRows_DocUp;}
  19. Im use to PHP and doing a query seems similar but i need help with syntax. I have an XML file that looks like this and i am trying to do a query where it will search for "ES2UA1" and i get the data "IP" and "Location" I know i am some where in the ball park with Dim doc = XDocument.Load(My.Application.Info.DirectoryPath & ".\xmlData.xml") Dim marker2 = From x In doc...<switchIP> _ Where x.SwitchName = "ES1UA1" _ Select x for each x as y msgbox(y.IP)
  20. Hi, you all know that from phpmyadmin you can run an SQL Query for example "select * from table where code like '0011'" now my question is can I add a query box like this directly into my website, so I can run a query without login into phpmyadmin? your help is very appreciated since I cannot make this happen. thanks
  21. I am trying to code a query whereby the query checks for duplicate items in a table and if found sends an error back to jquery. However, what is happening, is that jquery keeps giving me a typeError and I cannot see why. In my posted code, the code that is commented out, /* if ($box == 'DEMO111') works fine but not my query. All mysql connections are working and I can connect to the db. I would be grateful if someone could check my code and show me where I have gone wrong. Thanks DB Config <?php function runSQL($rsql) { $hostname = "localhost"; $username = "root"; $password = ""; $dbname = "logistor_logistor"; $connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database"); $db = mysql_select_db($dbname); $result = mysql_query($rsql) or die (mysql_error()); return $result; mysql_close($connect); ?> <?php $array = split('[,]', $_POST['box_add']); $boxerrortext = 'No duplicate boxes'; ?> <?php if (isset($_POST['submit'])) { $error = array(); foreach ($array as $box) { $sql = "SELECT * FROM act WHERE item = '" . $box . "'"; $result = runSQL($sql) or die(mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows) { //trigger_error('It exists.', E_USER_WARNING); $error[] = array('boxerror'=>$boxerrortext, 'box'=>$box); $result = json_encode($error); echo $result; return; } } /* if ($box == 'DEMO111') { //echo 'There was an error somewhere'; //$box = 'ERROR'; //$error = array('boxerror'=>$boxerrortext, 'box'=>$box); //$output = json_encode($error); //echo $output; //return; } */ else { $form = array(); foreach ($array as $box) { $form[] = array('dept'=>$dept, 'company'=>$company, 'address'=>$address, 'service'=>$service, 'box'=>$box, 'destroydate'=>$destroydate, 'authorised'=>$authorised, 'submit'=>$submit); $sql = "INSERT INTO `temp` (service, activity, department, company, address, user, destroydate, date, item, new) VALUES ('$service', '$activity', '$dept', '$company', '$address', '$requested', '$destdate', NOW(), '$box', 1)"; $result = runSQL($sql) or die(mysql_error()); } } } $result=json_encode($form); echo $result; ?>
  22. Hello! I found out that some 'SELECT' SQL queries are very slow with pdo_sqlite (PHP 5.3 or PHP 5.4). The same query entered in the sqlite3 binary is way faster. Here is my project : http://we.tl/59fGSVnAXh (password : "sqlite-php") - bench.php - chaines_centre.db - inc_func.php - info_job.php The info_job.php page performs 5 'SELECT' queries in 10 seconds with my Apache server. A same query is perform in less than 0.2 seconds in the sqlite3 binary (so theoretically 1 second for the whole page). I tried to modify the query a bit, and the results are strange : Benchmark (bench.php) on the « $bdd->query(...); » instruction : Query 2 : select DateMonteeAuPlan, Debut, Fin, Statut from ReportJobs where NomJob = 'NSAVBASE' and NomChaine like 'DCLC257%' limit 20; => 0.00099992752075195 seconde(s) Query 3 : select DateMonteeAuPlan, Debut, Fin, Statut from ReportJobs where NomJob = 'NSAVBASE' and NomChaine = 'DCLC25736' order by DateMonteeAuPlan DESC limit 20; => 0 seconde(s) Query 1 : select DateMonteeAuPlan, Debut, Fin, Statut from ReportJobs where NomJob = 'NSAVBASE' and NomChaine like 'DCLC257%' order by DateMonteeAuPlan DESC limit 20; => 1.8629999160767 seconde(s) Why is there so much differences between two query quasi-identical? How can I improve this situation to get results as fast as the sqlite3 binary? Thanks if you took the time to look out my project files.
  23. Hello guys. I execute a query and then put the records into array, the query has ORDER BY .... why I don't have the same order in the array?, If I execute the query, the record one it's no the same that $arreglo[0]. $stmt = $this->db->prepare('SELECT a.id_torneo, b.tor_nombre, a.id_jornada, a.id_juego, a.cal_fecha_hora, id_arbitro, a.cal_estatus, a.cal_default, c.id_equipo, d.equ_nombre, c.enc_locvis, e.id_jugador, e.jug_nombre_pila, e.jug_apellido_pat, e.jug_apellido_mat, e.jug_representante, e.jug_numero, jug_fechimp_reg FROM calendario a, torneo b, encuentro c, equipo d, jugador e WHERE a.id_cliente =? AND a.id_sucursal = ? AND date(a. cal_fecha_hora)= date(?) AND a.id_cliente = b.id_cliente AND a.id_sucursal = b.id_sucursal AND a.id_torneo = b.id_torneo AND a.id_cliente = c.id_cliente AND a.id_sucursal = c.id_sucursal AND a.id_torneo = c.id_torneo AND a.id_jornada = c.id_jornada AND a.id_juego = c.id_juego AND a.id_cliente = d.id_cliente AND c.id_sucursal = d.id_sucursal AND c.id_torneo = d.id_torneo AND c.id_equipo = d.id_equipo AND d.id_cliente = e.id_cliente AND d.id_sucursal = e.id_sucursal AND d.id_torneo = e.id_torneo AND d.id_equipo = e.id_equipo AND e.jug_estatus = "A" ORDER BY 5,11') or die(mysqli_error($this->db)); $stmt->bind_param("iis", $cliente, $sucursal, $fecha); $stmt->execute(); $stmt->bind_result($id_torneo, $tor_nombre, $id_jornada, $id_juego, $fecha_partido, $id_arbitro, $cal_estatus, $cal_default, $id_equipo, $equipo_nombre, $locvis, $id_jugador, $jug_nombre, $jug_apellidop, $jug_apellidom, $jug_rep, $jug_playera, $jug_fechareg); $arreglo = array() ; $contador = 0; while ($stmt->fetch()) { $arreglo[$contador] = array("id_torneo"=>$id_torneo,"torneo_nombre"=>$tor_nombre,"id_jornada"=>$id_jornada,"id_juego"=>$id_juego,"fecha_partido"=>$fecha_partido,"id_arbitro"=>$id_arbitro,"cal_estatus"=>$cal_estatus,"cal_default"=>$cal_default,"id_equipo"=>$id_equipo,"equipo_nombre"=>$equipo_nombre,"locvis"=>$locvis,"id_jugador"=>$id_jugador,"jug_nombre"=>$jug_nombre,"jug_apellidop"=>$jug_apellidop,"jug_apellidom"=>$jug_apellidom,"jug_rep"=>$jug_rep,"jug_player"=>$jug_playera,"jug_fechareg"=>$jug_fechareg); $contador++; }
  24. Hello, I have successfully installed PHP onto an IIS/SQL Server environment. I can get a DB connection and I can also post and display variables from one PHP page to another. I am trying to create a login script for a web application, but I am am having trouble getting any results from any select query that I write. Here is my login.php page: <body> <?php ob_start(); session_start(); $username = $_POST['username']; $password = $_POST['password']; $serverName = "localhost"; $connectionInfo = array("Database"=>"Derm", "UID"=>"xxxxxxxx", "pwd"=>"xxxxxxxxx"); $conn = sqlsrv_connect( $serverName, $connectionInfo); $query = "SELECT username, password, level, type, location FROM user_access WHERE username = '$username'"; $result = sqlsrv_query($conn, $query); if(sqlsrv_num_rows($result) == 0) // User not found. So, redirect to login_form again. { header('Location: index.html'); } $userData = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC); $hash = hash("sha512", $password); if($hash != $userData['password']) // Incorrect password. So, redirect to login_form again. { header('Location: index.html'); } else{ session_regenerate_id(); $_SESSION['username'] = $userData['username']; $_SESSION['level'] = $userData['level']; $_SESSION['type'] = $userData['type']; $_SESSION['location'] = $userData['location']; session_write_close(); header('Location: main.php'); } ?> </body> I have checked the query many times in SQL Server management studio and it always returns the correct result using my username. However, here, the page keeps refreshing itself and never progresses to 'main.php'. Is there a way to solve this or are there any alternatives to do the same thing? I don't actually want to display the query results, rather just assign them as session variables. Thanks
  25. Hii.. I had made a table in the database. And also had printed out the data... There are 20 episodes in a movie... And I had fetch and printed all the 20 episodes. Now I want to make those 20 lines clickable link and when user clicks on that link than it should perform some operation like in the thenewboston.org website when you click on Video & Tutorials Tab from the nav bar than it opens up all the topics. and when we click on for e.g. PHP VIDEOS than it takes to the particular page and than in the PHP Tutorials it shows a list of 200 videos and than when you click on any of the page than it fetch the data from database and than print the related data. So how should I make the dynamic links like http://thenewboston.org/watch.php?cat=11&number=21 ... And how should I write the operation in my php page which than performs the query and display it on that page... Any link referring to tutorial will work... Any Help would be appreciated.
×
×
  • 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.