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

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

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


Languages

  1. I am writing a CRUD and this is a test page to combine 3 separate files into one page. If I comment out the final "else" section entirely the first "if" section and the "else if" section work fine, no errors. After I remove the comment marks for the final "else" section I get this error: PHP Parse error: syntax error, unexpected '?>' in /public_html/crud/test.php on line 139 (<- the line 139 the error points to is the final php closing tag before the closing body tag) It should be obvious, simple, but I can't find any reason why it is throwing out that error and breaking the page (it is just a blank white page). I'm sure somebody can scan through the code and see what I'm missing. Thanks. <!DOCTYPE html> <html> <head> <?php require_once "../HeaderStuff.php"; require_once "../connection.php"; ?> <style> table { width: 100%; } th {background-color: #f1f1c1;} .margin {margin-top: 4em;} </style> </head> <body style="background-color:<?php echo $bgColor; ?>"> <?php $choice = $_GET['choice']; $id = $_GET['id']; if ($choice == 'blogsEdit') { ?> <table class="w3-table-all"> <thead> <tr> <th class="textBig w3-padding-32 w3-left-align">Website Administration - Edit Blog</th> </tr> </thead> </table> <?php $sql = "SELECT id, cat, Fdate, title, para1, story, pic, picAlt FROM blogs WHERE id = $id"; $result = mysqli_query($link, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { // Display each field of the records. $id=$row['id']; // the blog id $cat=$row['cat']; // the blog category $Fdate=$row['Fdate']; // the blog date $title=$row['title']; // short title of the blog $para1=$row['para1']; // the introduction paragraph $story=$row['story']; // the rest of the blog after the intro paragraph $pic=$row['pic']; // picture for the blog $picAlt=$row['picAlt']; // alt text for the picture ?> <fieldset> <form action="blogsUpdate.php" method="post"> <table class="w3-table-all"> <tr> <th>Category:</th> <td><?php echo $cat; ?></td> </tr> <tr> <th>Blog Date:</th> <td><input type="text" name="Fdate" value="<?php echo $Fdate; ?>" /></td> </tr> <tr> <th>Blog Title</th> <td><input type="text" name="title" size="150" value="<?php echo $title; ?>" /></td> </tr> <tr> <th>Intro Paragraph</th> <td><textarea name="para1" id="para1" cols="150" rows="5"><?php echo $para1; ?></textarea></td> </tr> <tr> <th>Story</th> <td><textarea name="story" id="story" cols="150" rows="10"><?php echo $story; ?></textarea></td> </tr> <tr> <th>Picture File Name</th> <td><input type="text" name="pic" size="50" value="<?php echo $pic; ?>" /></td> </tr> <tr> <th>Picture Alt Text</th> <td><input type="text" size="150" name="picAlt" value="<?php echo $picAlt; ?>" /></td> </tr> <tr> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <td colspan="2"><button type="submit">Save Changes</button></td> </tr> </table> </form> </fieldset> <?php } } else { echo "0 results"; } } else if ($choice == 'lessonsEdit') { ?> <table class="w3-table-all"> <thead> <tr> <th class="textBig w3-padding-32 w3-left-align">Website Administration - Edit Lesson</th> </tr> </thead> </table> <?php $sql = "SELECT id, cat, Fname FROM blogs WHERE id = $id"; $result = mysqli_query($link, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { // Display each field of the records. $id=$row['id']; // the lesson id $cat=$row['cat']; // the lesson category $Fname=$row['Fname']; // the file name ?> <fieldset> <form action="lessonsUpdate.php" method="post"> <table class="w3-table-all"> <tr> <th>Category:</th> <td><?php echo $cat; ?></td> </tr> <tr> <th>File Name:</th> <td><input type="text" name="Fname" value="<?php echo $Fname; ?>" /></td> </tr> <tr> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <td colspan="2"><button type="submit">Save Changes</button></td> </tr> </table> </form> </fieldset> <?php } } else { echo "0 results"; } } else ($choice == 'writsEdit') { ?> <table class="w3-table-all"> <thead> <tr> <th class="textBig w3-padding-32 w3-left-align">Website Administration - Edit Writing</th> </tr> </thead> </table> <?php $sql = "SELECT id, cat, title, story FROM blogs WHERE id = $id"; $result = mysqli_query($link, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { // Display each field of the records. $id=$row['id']; // the writing id $cat=$row['cat']; // the category $title=$row['title']; // title of the writing $story=$row['story']; // the poem or story ?> <fieldset> <form action="writsUpdate.php" method="post"> <table class="w3-table-all"> <tr> <th>ID:</th> <td><?php echo $id; ?></td> </tr> <tr> <th>Category:</th> <td><?php echo $cat; ?></td> </tr> <tr> <th>Title</th> <td><input type="text" name="title" size="150" value="<?php echo $title; ?>" /></td> </tr> <tr> <th>Story</th> <td><textarea name="story" id="story" cols="150" rows="10"><?php echo $story; ?></textarea></td> </tr> <tr> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <td colspan="2"><button type="submit">Save Changes</button></td> </tr> </table> </form> </fieldset> <?php } } else { echo "0 results"; } } ?> </body> </html>
  2. CHALLENGE (WELL, KIND OF): Please find below two sets of code. The first is a short-hand snippet of code fits that within a larger block of code. The second is my own long-hand interpretation of what it means. SHORT-HAND: $str_browser_language = !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ',') : ''; $str_browser_language = !empty($_GET['language']) ? $_GET['language'] : $str_browser_language; LONG-HAND: if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $str_browser_language = strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ','); } else { if (!empty($_GET['language'])) { $str_browser_language = $_GET['language']; } else { $str_browser_language = ''; } } QUESTION: Is my interpretation correct? If not, please explain, in what manner I have erred. Roddy
  3. Hi. How can I open the read more link in a new page. Just like Facebook when you click on the continue reading, it shows the current clicked post in a new page.
  4. Hello frns, i learnt how to get the gps coordinates from w3school tutorials but a small question how to alter the user if he blocks the gps access request through code <script> var x = document.getElementById("gpsloc"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, showError); } else { x.value = "Geolocation is not supported by this device."; } } function showPosition(position) { x.value = position.coords.latitude + "," + position.coords.longitude; } function showError(error) { switch(error.code) { case error.PERMISSION_DENIED: x.value = "User denied the request for Geolocation." break; case error.POSITION_UNAVAILABLE: x.value = "Location information is unavailable." break; case error.TIMEOUT: x.value = "The request to get user location timed out." break; case error.UNKNOWN_ERROR: x.value = "An unknown error occurred." break; } } </script> what i want to make is page should check the state of permission and if permission is denied page should alert or keep re-request permission to allow please assist
  5. How to avoid form resubmission <?php require_once('../Connections/localhost.php'); ?> <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "../app/index.php?la=r"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_teachers = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_teachers = $_SESSION['MM_Username']; } mysql_select_db($database_localhost, $localhost); $query_teachers = sprintf("SELECT * FROM teachers WHERE employee_id = %s", GetSQLValueString($colname_teachers, "text")); $teachers = mysql_query($query_teachers, $localhost) or die(mysql_error()); $row_teachers = mysql_fetch_assoc($teachers); $totalRows_teachers = mysql_num_rows($teachers); $colname_school = "-1"; if (isset($row_teachers['school_id'])) { $colname_school = $row_teachers['school_id']; } mysql_select_db($database_localhost, $localhost); $query_school = sprintf("SELECT * FROM schools WHERE id = %s", GetSQLValueString($colname_school, "int")); $school = mysql_query($query_school, $localhost) or die(mysql_error()); $row_school = mysql_fetch_assoc($school); $totalRows_school = mysql_num_rows($school); date_default_timezone_set("Asia/kolkata");?> <!doctype html> <html lang="en"> <head> <meta http-equiv="Refresh" content="1600"> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="../app/css/app.css" type="text/css"> <?php include('../app/includes/favicon.php'); ?> <meta name="Description" content="Andhra Pradesh Department of School Education Teacher & Student online Attendence with Photo Geo Tagging "> <title>Location Check</title> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> </script> <![endif]--> </head> <body> <?php include('../app/includes/header.php'); ?> <marquee direction="left"> <h2>DEPARTMENT OF SCHOOL EDUCATION</h2> </marquee> <main> <nav> <ul> <li><a href="../app/teacher1.php">HOME</a></li> <li><a href="../app/test.php">MDM</a></li> <li><a href="<?php echo $logoutAction ?>">Logout</a></li> <li></li> </ul> </nav> <article> <fieldset> <legend>Local Storage Test</legend> <form id="geotag" method="post" enctype="multipart/form-data" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"> <table width="auto" align="center"> <tbody> <tr> <td><label class="cameraikon" for="image"></label></td> </tr> <tr> <td> <input id="image" type="file" name="image" accept="image/*" capture="camera" onChange="this.form.submit()"> </td> </tr> <tr><td><input type="button" id="upload" value="upload"></td></tr> <tr><td><div id="loader" style="display: none"></div></td></tr> <tr><td height="auto" style="margin-top: 50px;"> <?php if(isset($_FILES['image']['name'])){ $img = $_FILES['image']['tmp_name']; $targDir="../app/geotagged_imgs/"; $imgExtension= strtolower(pathinfo(basename($_FILES['image']['name']),PATHINFO_EXTENSION)); $imgname = "APEDU_".date('d-m-Y_h|i|s').".".$imgExtension; $tmpimg=imagecreatefromjpeg($img); imagejpeg($tmpimg,$targDir.$imgname,50); // move_uploaded_file($_FILES['image']['tmp_name'],$targDir.$imgname); echo '<p id = "result">'.$imgname.'<br>UPLOADED SUCCESSFULLY.</p><br>'; imagedestroy($tmpimg); echo '<br><img src="../app/geotagged_imgs/'.$imgname.'" class="thumbnail"><br>'; empty($_FILES['image']['name']); empty($_FILES['image']['tmp_name']); print_r($_FILES['image']['name']); } ?> </td></tr> </tbody> </table> </form> </fieldset> </article> </main> <footer> ™ and © 2019 A M Productions. All rights reserved. Property of Sikander. Use of this website (including any and all parts and components) constitutes your acceptance of these Terms and Conditions and Privacy Policy. Ad Choices. The materials on this website are not to be sold, traded or given away. Any copying, manipulation, publishing, or other transfer of these materials, except as specifically provided in the terms and conditions of use, is strictly prohibited. Smoking Policy</footer> </body> </html> <script> y = document.getElementById("upload").addEventListener("click",sikki); function sikki() { document.getElementById("loader").style.display = "block"; } </script> <?php mysql_free_result($teachers); mysql_free_result($school); ?>
  6. BACKGROUND: I have a page that, when loaded, creates several values via PHP. These values are assigned to several Javascript variables on the same page. I have verified that the assignment succeeds. When a visitor clicks on the page a visible div on the page is filled with the content of another div on the same page page, and additional javascript and CSS are loaded from another document. I have verified that this latter load does succeed, and that at least one of the functions contained therein is accessible. DILEMMA: Unfortunately, this freshly loaded Javascript is unable to find the values of the Javascript variables to which the PHP values were assigned when the page was initially downloaded. QUESTION ONE: What are the plausible reasons for not being able to find the relevant variables? QUESTION TWO: How do I make them findable? Roddy
  7. So i'm not still really familiar with regex and how does it work, but i have issue with my code. I have ¤ in my text and it gets replace with unicode ? block. https://en.wikipedia.org/wiki/Specials_(Unicode_block) for me and I don't get why. Here is the code I'm using. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> #kool { width:800px; border:groove; margin:0 auto; padding:25px; } </style> </head> <body> <?php /* Test preg_replace function */ $preg_pattern = "/[^A-Za-z0-9!\"#%£&()=@\s]/"; if (isset($_GET['preg'])) { echo "<div id='kool'>"; echo "<b>Original string: </b> " . $_GET['preg']; echo "<hr>"; echo "<b>Preg pattern: </b> " . $preg_pattern; echo "<hr>"; echo "<b>Result: </b> " . preg_replace($preg_pattern,"",$_GET['preg']); echo "</div>"; } ?> <form method="get" action="preg_test.php"> <input type="text" name="preg" <?php if (isset($_GET['preg'])) { echo " value='" . $_GET['preg'] . "'"; } ?>> <input type="submit"> </form> </body> </html> And here is the string I'm trying to use. Test 0-9, Specialcharacters: !"#¤%&/()=? Result image below Any guides / help appreciated.
  8. Is it possible to use this lightbox code with multiple galleries? At the moment, when using it with different galleries, lightbox will pop up, but it only show first gallery, and the others won't display. I have implemented this lightbox code with my PHP code and for the first gallery, everything is fine, but when I click others, only those gallery thumbnails will show up, but the currentSlide isn't and I understand that code changes only in the first gallery. My code: <div class="row"> <div class="row-inner" id="ajax-posts"> <?php while( $refs->have_posts() ): $refs->the_post(); // get_template_part('content/content', 'reference'); $galleryarray = get_post_gallery_ids($post->ID); ?> <div class="gridbox reference <?php if(DOING_AJAX) {echo " added";} ?>"> <a> <div class="bg_img cursor"<?php if ( $thumbnail_id = get_post_thumbnail_id() ) { if ( $image_src = wp_get_attachment_image_src( $thumbnail_id, 'normal-bg' ) ) printf( ' style="background-image: url(%s);"', $image_src[0] ); } ?> onclick="openModal(<?php echo $i; ?>);currentSlide(<?php echo $id ?>)"> </div> <h3><?php the_title(); ?></h3> <p><?php the_time('Y'); ?><br><?php the_category( ', ' ); ?></p> </a> </div> <!-- Modal --> <div id="myModal-<?php echo $i; ?>" class="modal"> <span class="close cursor" onclick="closeModal(<?php echo $i; ?>)">&times;</span> <div class="modal-content"> <?php foreach ($galleryarray as $index => $id) { $image = wp_get_attachment_image_src( $id, ‘thumb’ ); /* $attachment_meta = wp_get_attachment( $id );*/ $number = $index+1; ?> <div id="img-<?php echo $id; ?>" class="mySlides"> <div class="numbertext"><?php echo $number; ?> / <?php echo count($galleryarray); ?></div> <img id="<?php echo $id; ?>" src="<?php echo $image[0]; ?>" style="width:100%"> </div> <?php } ?> <a class="prev" onclick="plusSlides(-1)">&#10094;</a> <a class="next" onclick="plusSlides(1)">&#10095;</a> <div class="caption-container"> <p id="caption"></p> </div> <?php foreach ($galleryarray as $index => $id) { $image = wp_get_attachment_image_src( $id, ‘thumb’ ); /* $attachment_meta = wp_get_attachment( $id );*/ $alt = get_post_meta( $id, '_wp_attachment_image_alt', true); $number = $index+1; ?> <div class="column"> <img id="<?php echo $id; ?>" class="demo cursor" src="<?php echo $image[0]; ?>" style="width:100%" onclick="currentSlide(<?php echo $number ?>)" alt="<?php echo $alt; ?>"> </div> <?php } ?> </div> </div> <?php $i++; endwhile; ?> </div> </div> function openModal(i) { document.getElementById('myModal-'+i).style.display = "block"; document.getElementById('pageHeader').style.zIndex = "0"; document.getElementById('pageFooter').style.zIndex = "0"; document.getElementById('pageContainer').style.textAlign = "left"; } function closeModal(i) { document.getElementById('myModal-'+i).style.display = "none"; document.getElementById('pageHeader').style.zIndex = "10"; document.getElementById('pageFooter').style.zIndex = "9"; document.getElementById('pageContainer').style.textAlign = "center"; } var slideIndex = 1; showSlides(slideIndex); function plusSlides(n) { showSlides(slideIndex += n); } function currentSlide(n) { showSlides(slideIndex = n); } function showSlides(n) { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("demo"); var captionText = document.getElementById("caption"); if (n > slides.length) {slideIndex = 1} if (n < 1) {slideIndex = slides.length;} console.log(slideIndex); for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; captionText.innerHTML = dots[slideIndex-1].alt; } Is it possible to change that code somehow to get it working, or maybe better solution is to sum up every gallery array to one, and make one Modal, where those galleries pop up only when clicking on the right gallery?
  9. Hi ! On of the tutorial pages https://www.w3schools.com/js/js_json_html.asp is missing code of php file. As I understand the code should be the same as on previous page of chapter, like: <?php $myObj->name = "John"; $myObj->age = 30; $myObj->city = "New York"; $myJSON = json_encode($myObj); echo $myJSON; ?> Sincerely, Alejandro.
  10. I have 3 fields that are the same name as corresponding column in MySQL database. First field is a dynamic dropdown list called "eventname". Second field called "eventdate" is an input field that gets populated via choice made from "eventname" dropdown list / First field. Third field called "venuename" is an input field that gets populated via choice made from "eventname" dropdown list / First field. What this dynamic dropdown list does is select the eventname from database then there is an onchange function that pulls out corresponding data from same line for the eventdate and venuename and sets them in the corresponding input field. All works as they should and data gets entered to the MySQL database. Only one issue: "eventname" choice from dropdown list should be submitted as "eventname" the displayed choice, what happens is my code enters data in MySQL as "eventdate | venuename" and my desired result should only be "eventname" The PHP <select id="eventname" onchange="eventFunction(eventname)"> <option selected="selected"></option> <?php foreach ($event as $event) { ?> <option value="<?php echo $event['eventdate'] .'|'. $event['venuename']?>"><?php echo $event['eventname'] ?></option> <?php } ?> </select> Date: <input id="eventdate"> Venue: <input id="venuename"> and the JavaScript <script> function eventFunction(eventname){ var eventDetails = eventname.options[eventname.selectedIndex].value.split("|"); document.getElementById("eventdate").value=eventDetails[0]; document.getElementById("venuename").value=eventDetails[1]; } </script> NOTE: If I touch the value attribute ie value="<?php echo $event['eventdate'] .'|'. $event['venuename']?>" the javascript wont work. I am a begginer with coding using JavaScript, can someone help me solve this please with examples. Thanx.
  11. CAN ANYONE HELP? I just upgraded Joomla to the newest version. When I tried to login to the admin i cannot get to anything except this error message: Error: Unknown column 'a.client_id' in 'where clause': Unknown column 'a.client_id' in 'where clause' Can anyone tell me where to start to fix this? Thanks
  12. BACKGROUND: Many moons ago it was suggested that I create a CRON job that would read into a MySQL table the results of a method call to a Matomo API call and thereby speed up the rendering of data for visitors to the Grammar Captive website. I have since come to learn that this technique is called data translation. The following code creates a class object that when inserted into a foreach loop is suppose to fill the properties of the object for further manipulation. Unfortunately it does perform the intended task. THE CLASS class TranslateMatomoAction { public $mysqli_obj; public $visitID; public $type; public $serverTimePretty; public $timestamp; public $url; public $generationTime; public $pageTitle; public $pageID; public $pageView_ID; public $pageID_Action; public $timeSpent; public $eventCategory; public $eventAction; public $eventName; public function __construct($property, $value) { if ($property === 'type') { $this->type = $value; } else if ($property === 'serverTimePretty') { $this->serverTimePretty = $value; } else if ($property === 'timestamp') { $this->timestamp = $value; } else if ($property === 'url') { $this->url = $value; } else if ($property === 'generationTimeMilliseconds') { $this->generationTime = $value; } else if ($property === 'pageTitle') { $this->pageTitle = $value; } else if ($property === 'pageId') { $this->pageID = $value; } else if ($property === 'idpageview') { $this->pageView_ID = $value; } else if ($property === 'pageIdAction') { $this->pageID_Action = $value; } else if ($property === 'timeSpent') { $this->timeSpent = $value; } else if ($property === 'eventCategory') { $this->eventCategory = $value; } else if ($property === 'eventAction') { $this->eventAction = $value; } else if ($property === 'eventName') { $this->eventName = $value; } } public function set_visitID($visitID) { $this->visitID = $visitID; } public function set_mysqli_obj($mysqli_obj) { $this->visitID = $visitID; } } THE INSERTED CLASS AND ASSOCIATED CODE if (is_array($value1) && ($key1 === 'actionDetails')) { foreach($value1 as $key2 => $value2) { //LEVEL 2 - This foreach statement traverses the set of indexed arrays whose elements are a key-value pair of indices and arrays. Each array is a value of the actionDetails element of a visit. if (is_array($value2)) { $matomo_action = new TranslateMatomoAction($key3,$value3); foreach($value2 as $key3 => $value3) { //LEVEL 3 - This foreach statement traverses the elements of the associative array corresponding to the value of $key2. $matomo_action($key3, $value); } } } } DILEMMA: Unfortunately, the above procedure fails to fill the values of the object's property as expected. QUESTION: Where have I gone wrong? Roddy
  13. 0 down vote favorite BACKGROUND: I have built a custom search engine that works fine in English, but fails in Japanese, this despite confirmation from my host server that I have performed the installation of the Japanese mecab parser correctly. My own checks reveal the following: 1) SHOW CREATE TABLE: FULLTEXT KEY search_newsletter (letter_title, letter_abstract, letter_body) /*!50100 WITH PARSER mecab */ ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 2) SHOW PLUGINS: ngram | ACTIVE | FTPARSER | NULL | GPL | mecab | ACTIVE | FTPARSER | libpluginmecab.so | GPL IMPLEMENTATION 1) MYSQL Statement: $sql ="SELECT letter_no, letter_lang, letter_title, letter_abstract, submission_date, revision_date, MATCH (letter_title, letter_abstract, letter_body) AGAINST (? IN NATURAL LANGUAGE MODE) AS letter_score FROM sevengates_letter WHERE MATCH (letter_title, letter_abstract, letter_body) AGAINST (? IN NATURAL LANGUAGE MODE) ORDER BY letter_score DESC"; 2) CUSTOM SEARCH ENGINE: See under Local Search / Newsletters at https://www.grammarcaptive.com/overview.html 3) DOCUMENT SEARCHED: See under Regular Updates / Newsletter / Archives / Japanese at https://www.grammarcaptive.com/overview.html COMMENT: Neither PHP, nor MySQL complains. Simply any Japanese word search that needs to be parsed is not returned. For example, the word 日本語 can be search and found, but does not require any parsing to be retrieved. The search for any other Japanese word in the newsletter fails. REQUEST: Any troubleshooting tips would be greatly appreciated. Roddy
  14. Hi there, I went into a problem, might be simple for you but I am sitting here and try it out for many many many hours... Here is the thing, at the top is my header, the header is seperated with php in another file/folder and with a php code it is displaying in the index home file. I would like to have the background video fully covered under my content body and under my header. But whenever I put it, then it is under my content only and the header is disappearing for some reason. Also, when I put it for header only, then I will get it at the top only and the body will be empty with my normal content but without the background video. Here is the code I am using: #CSS * { box-sizing: border-box; } body { margin: 0; font-family: Arial; font-size: 17px; } #myVideo { position: fixed; right: 0; bottom: 0; min-width: 100%; min-height: 100%; } HTML <video autoplay muted loop id="myVideo"> <source src="https://www.belloo.date/upgrade/themes/landing2/images/bg.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video> I put the CSS at the top in the header section and the other stuff in front of my body content. Any suggestions? :(
  15. hello all. i was just wondering between these two versions of PHP - 5 & 7. right now i'm practicing on if PHP 5. and now i'm thinking of upgrading to PHP 7. and i want to know if my current code works with the new version or not. if i upgraded my PHP to 7, should i need to change all or some parts of the codes? thank you in advance.
  16. Hello, I am trying to upload images with php...I followed the instructions step by step and it just not working...The following error code is Warning: getimagesize(): Filename cannot be empty in: ..............I copied the code from here.
  17. No keywords are highlight. for what reason behind that. please help me Here is my HTML code and at the bottom PHP. HTML CODE: <form id="nbc-searchblue1" method="post" enctype="multipart/form-data" autocomplete="off"> <input type="text" id="wc-searchblueinput1" class="nbc-searchblue1" value="<?php echo $search; ?>" placeholder="Search Iconic..." name="search" type="search" autofocus> <br> <input id='nbc-searchbluesubmit1' value="Search" type="submit" name="button"> </form> PHP CODE: <?php // We need to use sessions, so you should always start sessions using the below code. session_start(); // If the user is not logged in redirect to the login page... if (!isset($_SESSION['loggedin'])) { header('Location: ../index.php'); exit(); } include 'connect.php'; $search = $sql = ''; if (isset($_POST['button'])){ $numRows = 0; if (!empty($_POST['search'])){ $search = mysqli_real_escape_string($conn, $_POST['search']); $sql = "select * from iconic19 where student_id like '%{$search}%' || name_bangla like '%{$search}%' || name like '%{$search}%' || phone like '%{$search}%' || blood like '%{$search}%' || district like '%{$search}%'"; $result = $conn->query($sql); $numRows = (int) mysqli_num_rows($result); } if ($numRows > 0) { echo "<table> <thead> <tr> <th><b>Photo</th> <th><b>Student ID</th> <th style='font-weight: 700;'><b>নাম</th> <th><b>Name</th> <th><b>Mobile No.</th> <th><b>Blood Group</th> <th><b>Email</th> <th style=' font-weight: 700;'><b>ঠিকানা</th></tr></thead>"; while ($row = $result->fetch_assoc()){ $student_id = !empty($search)?highlightWords($row['student_id'], $search):$row['student_id']; $name = !empty($search)?highlightWords($row['name'], $search):$row['name']; $district = !empty($search)?highlightWords($row['district'], $search):$row['district']; echo "<tbody>"; echo "<tr>"; echo "<td>" . "<div class='avatar'><a class='fb_id' target='_blank' href='https://www.facebook.com/" . $row['fb_id'] . "'><img src='" . $row['photo'] . "'><img class='img-top' src='fb.png'></a>" . "</td>"; echo "<td data-label='Student ID'>" . $row['student_id'] . "</td>"; echo "<td data-label='নাম' style=' font-weight: 700;'>" . $row['name_bangla'] . "</td>"; echo "<td data-label='Name' style='font-weight:bold;' >" . $row['name'] . "</td>"; echo "<td data-label='Mobile No'>" . "<a href='tel:" . $row['phone'] . "'>" . $row['phone'] . "</a>" . "</td>"; echo "<td data-label='Blood' style='color:red; font-weight:bold;' >" . $row['blood'] . "</td>"; echo "<td data-label='Email'>" . "<a href='mailto:" . $row['email'] . "'>" . $row['email'] . "</a>" . "</td>"; echo "<td data-label='ঠিকানা' style='font-weight: 700;'>" . $row['address_bangla'] . "</td>"; echo "</tr>"; echo "</tbody>"; } } else { echo "<div class='error-text' style='font-weight: 700;'>No Result</div><br /><br />"; } } $result = $conn->query("SELECT * FROM iconic19 $sql ORDER BY id DESC"); function highlightWords($text, $word){ $text = preg_replace('#'. preg_quote($word) .'#i', '<span style="background-color: #F9F902;">\\0</span>', $text); return $text; } $conn->close(); ?>
  18. Hi, I am having a very hard time debugging & running the following query from a cell on php or pma. $sql = "UPDATE crypto SET crypto_openssl_recommendation = 1 WHERE (\"%ECB%\" OR \"%RC2%\" OR \"%RC4%\" OR \"%DES%\" OR \"%3DES%\" OR \"%MD5%\") LIKE UPPER(crypto_descr);"; The table is meant to keep track of OpenSSL encryption methods, and their availability and recommendation over CryptoJS wether used in Javascript, or JScript. This query is meant to update the recommendation, but the quality of my MySQL querying has wilted a bit in the past four years.
  19. Hi, the error log says that the executing document has an unexpected quotation mark in line 32, however - the lines following the http 500 error from the php error_log - come from crypto_methods.php and are printed below... (all sensitive information has been replaced with *****) [05-Feb-2019 19:20:58 UTC] PHP Parse error: syntax error, unexpected '"' in /home/*****/public_html/crypto_methods.php on line 32 31. foreach ($ciphers as $key => $value) { 32. $sql = "INSERT INTO crypto (crypto_no, crypto_descr) VALUES (" . $key . ", /"" . $value . "/");"; 33. $result = $conn->query($sql); 34. }
  20. Hi again, moved the topic to a new one because it no longer uses PCRE. I have the physical problem of having lost my dev pc and 24" screens, now having to make do with android on a 3.5" touchscreen. So the issue i have encountered is again a likeness of this time a bit more physically - "not being able to see the forest for the trees", as my viewing area has been greatly diminished. The code is below, with the php error_log thereafter. <?php $t = intval($_GET["t"]); switch ($t) { case 1: header('Content-Type: Text/XML'); break; case 2: header('Content-Type: Text/JavaScript'); break; case else: header('Content-Type: Text/HTML5'); ?><!DOCTYPE html> <html lang="en-za"> <head> <meta charset="UTF-8"> <title>*** Test Page</title> </head> <body> <p><a href="http://***.com/default.php?t=0&u=Sof00207&f=c&r=45">*** Test Page</a></p><br /> <p> <pre><? /* Initiate Variables for URL: http://***.com/default.php?t=0&u=Sof00207&f=c&r=45 1. Key Field: C 2. Key Row: 45 3. Account Number: Sof00207 4. Month: G 5. Number Of Licenses: 5 6. Active: Y/N: J 7. Licences Used: 3 8. Year: J 9. Module 1: A 10. Module 2: 1 11. Module 3: B 12. Module 4: 0 */ $f = strtoupper($_GET["f"]); $r = intval($_GET["r"]); $f = dirname(__FILE__) . "/RegUploads/" . $_GET["u"] . "#" . $f . $r . ".xml"; print $f . "\r\n\r\n"; if (file_exists($f)) { $ret = file_get_contents($f); print htmlentities($ret); } $servername = "localhost"; $username = "***"; $password = "***"; $dbname = "***"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // echo "Connected successfully"; $q = intval($_GET["q"]); switch ($q) { case 0: // Return Encryption Key by Field A/B/C/D & Row ID // Define SQL String $sql = "SELECT * FROM `Sleutels` WHERE `ID` = " . $r . ";"; $result = $conn->query($sql); if ($result->num_rows > 0) { print "\"" . $sql . "\"<br />\r\n"; // output data of each row while($row = $result->fetch_assoc()) { print "Key: " . htmlencode($row[$f]). "<br />\r\n"; }; } else { print "\"" . $sql . "\"<br />\r\n"; print "0 results<br />\r\n"; }; break; case 1: echo "q equals 1"; break; case 2: echo "q equals 2"; break; }; ?></pre> </p> </body> </html><? }; $conn->close(); ?> [30-Jan-2019 19:42:33 UTC] PHP Parse error: syntax error, unexpected 'else' (T_ELSE) in /home/dwtnfwfv/public_html/default.php on line 11
  21. Greywacke

    pcre query

    hi all, long time no see... i have a php document which needs to test the entire querystring such as follows: http://verifyreg.com/?c0078#Sof00207#G5J3!J@A1B0 now to process this querystring without variables... i have the following code: // Initiate Variables 1. Key Field 2. Key Row $p = `|(A-Da-d1-4)0*(1-100)#(^#)#(^@)@(*)|U`; $q = $_GET; $m = new Array(); $ret = preg_match_all($p,$q,$m); if ($ret !== false && $ret > 0) { print_r($m.$ret); } however the part after the first # will all be encoded eventually... the first part is to define the field to select the key from, the second part is the row, for the current session. the key will be used on the serverside to encrypt the rest of the querystring after the first #.
  22. khan.sikki

    Seating Layout

    Hello Friends, Can anyone help in designing seating layout and linking the rows and columns with Database table Regards, Sikandar
  23. I'm making a simple contact form which works and I would like to have the user add in either their phone number OR their email. Both are fine, but at least one is required. I don't want to require both. Anyway, I created an if statement in my php code which works but when I have it return to the form, of course the form has been cleared of the user input. I then decided to create a javascript statement that does the same thing, but it clears the form as well. I personally hate it when that happens to me, so I want to make sure that whoever is filling out the form doesn't lose their information if they forget to input their phone number or email. I'm just learning to code, so I'm not sure what I should do to fix this problem. Is there some sort of HTML code I could use so that one of the two is required before the user hits the submit button? As I said before, I don't want to use the required function for either input. I appreciate any response! 😊
  24. Currently I am working on a project and I faced this problem i want to hide the parameters from URL that are passed. I am working on a site http://letsfindcourse.com and I want to hide the parameters from URL so how can I do that ?
  25. I had an array with duplicates. I removed the duplicates using PHP array_unique function. Then, I loop through the unique array using for loop (Sample Code below) and , I got an Undefined offset error. $even_numbers = array(22,66,24,22,36); $unique_even_numbers = array_unique($even_numbers); for($i=0; $i<count($unique_even_numbers); $i++){ echo $unique_even_numbers[$i].'<br>'; } The interesting thing is that I forgot I removed duplicates from the array somewhere (and therefore, an index). It took me something to figure out what was happening. I then used foreach. If I'm not missing something then I think it will be helpful if this is mentioned somewhere in the w3schools tutorial. It may help especially beginners.
×
×
  • Create New...