PHP - Explanation Needed
If I am trying to say something like:
if a variable is not empty, would I do this? if ($id != "") or does the "" mean ANYTHING instead of NOTHING? The reason I'm asking is because my home.php page does not have an id associated with it when a person first comes to the site, but when a user clicks on the "home" links then the id for the home page is set to 13. So I get an error for some of the lines when a user first visits the page because all the info for the page is based on the id (which isn't set yet). home.php is pointed to by my controller index.php script which so far only says <?php include $_SERVER['DOCUMENT_ROOT'] . './includes/magicquotes.inc.php'; include $_SERVER['DOCUMENT_ROOT'] . './includes/db.inc.php'; include 'home.php'; ?> is there a way to make the include 'home.php'; line point to something like include 'home.php?id=13' without having to have an actual file called home.php?id=13 on the server? Thanks Similar TutorialsHello everyone, Can somebody help me? I am a novice in PHP programming. I do not understand a line of code below: $action = isset($_GET['action']) ? $_GET['action'] : ''; The variables $action saves the values obtained by the GET method, but what does this piece of code ? $_GET['action'] : ''; Thanks in advance! I just want to clarify what this line means...
<?php if(get_post_meta($id, "title_override_text", true) !== '') { ?>Is this saying, if 'title_override_text' exists but doesn't contain any value? Thanks in advance. I'm getting a strange error for this code, but i'm unable to find out what's wrong, the error is below: Quote Parse error: parse error, expecting `'&'' or `T_VARIABLE' in on line 12 Here's the code: function CMySQL_Create($Username, $Password, bool:$md5 = true) { switch($md5) { case false: { mysql_query("INSERT INTO " . $ACCOUNT_TABLE . " (" . $USERNAME_FIELD . ", " . $PASSWORD_FIELD . ") VALUES('" . mysql_real_escape_string($Username) . "', '" . mysql_real_escape_string($Password) . "')") or die(mysql_error()); } case true: { mysql_query("INSERT INTO " . $ACCOUNT_TABLE . " (" . $USERNAME_FIELD . ", " . $PASSWORD_FIELD . ") VALUES('" . mysql_real_escape_string($Username) . "', md5('" . mysql_real_escape_string($Password) . "'))") or die(mysql_error()); } } } The line of this error is: function CMySQL_Create($Username, $Password, bool:$md5 = true) { Any clue? Hi guys. First of, English is not my spoken language so have patience I've google it and done some reading regarding "hard refresh" but i cant find the information i'm looking for. Lets say that i visit a website that i've visit 6 month earlier, and what if they done some changes that require a so called hard refresh. How should people know that the site require a ctrl+5? I mean, i could be visit sites that looks different without my knowledge, that could been changed several month ago? How does it work? Is it manage automatically or is it up to the webmaster to implate some codes like Code: [Select] <?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?> I dont know much about site development and i try to learn as much as i can. Is there no better way to handle this. And my second question. Where should i paste codes like this to solve the cache problem? In the header.php? My site keeps track of people using cookies. This is stored in $cookie['supercookie']; There area mods who can recommend normal posters to become mods. What it does its sends the persons cookie to recommend.php recommend.php looks like this. Note when i recommend someone, for some reason my cookie gets unset and it will not let me set a new cookie. I literally don't understand why as the $_cookie['supercookie'] variable is NEVER referneced. i read the GET info containing their cookie, check to see its not and admin or mod, then if they are not i submit their cookie to the pword table and get their uname (this isnt alwatys set) -> Then i add it into a pending table. The script executes perfectly, however for some weird reason it unsets my cookie and wont let me set another one. Its doing my head in. <?php session_start(); include $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; if(isset($_SESSION['lv'] )AND $_SESSION['lv'] > 4){ $pass = "*Private*"; if(isset($_GET['cook'])){ $recby = "Not recorded"; $ck = protect($_GET['cook']); if(!_is_admin($ck) && !_is_mod($ck)){ //everything is fine. //uname,pass,scookie,recby //get details. $res = mysql_query("SELECT * FROM pword WHERE scookie = '$ck'AND level = 'Norm' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($res); $uname = stripslashes($row['uname']); mysql_query("INSERT INTO nwg (uname,pass,scookie,recby) VALUES ('$uname','$pass','$ck','$recby')")or die(mysql_error()); add_notice("User: <strong>$uname</strong> has been recommended"); echo "<script>location.href='http://www.imgboard.co.uk/'</script>"; } else{ add_notice("You shouldn't have been able to do that!"); addaction(8,"Recommended /kbos"); echo "<script>location.href='http://www.imgboard.co.uk/'</script>"; die(); } } else{ add_notice("You need to specify a cookie id!"); echo "<script>location.href='http://www.imgboard.co.uk/'</script>"; die(); } } else{ add_notice("Restricted Area"); echo "<script>location.href='http://www.imgboard.co.uk/'</script>"; die(); } ?> Hey guys, I need some help with a small project I'm doing. I have a radio receiver hooked up to a serial port and have it streaming on a web page. I need to create a spectrum plot which will show the given frequency strength. I have the chart all ready i just need a way to extract the data from the radio so it goes onto the graph. Anyone know how to do this ? Also for the chart i will be using google charts Hello i have coded a script that checks the post values then updates db recoreds thing is. i have this line of code if($name && $price && $ship && $paypal && $des && $cato_id !== ""){ do code }else{ do this } when the client enters 0 in the ship and price the do code does not get excuted how can i solve this problem thanks <?php # Script 10.3 - upload_image.php // This page is for editing a product. require_once(MYSQL);; // Check for a valid product ID, through GET or POST: if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; // Make the query: $q = "SELECT name, price, ship, paypal, descr FROM products WHERE product_id='$id' LIMIT 1"; $r = mysqli_query ($dbc, $q); if(mysqli_affected_rows($dbc) == 1) {//Ran Ok ready to delete file $row = mysqli_fetch_array ($r, MYSQLI_ASSOC); } } else { die('<p class="error">Sorry this page is not available or has been accessed in error</p>'); } // Check if the form has been submitted: if (isset($_POST['submitted'])) { require_once(MYSQL); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $name = $price = $ship = $paypal = $des = $cato_id = FALSE; // Check for a product name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['name'])) { $name = mysqli_real_escape_string ($dbc, $trimmed['name']); } else { echo '<p class="error">Please enter a product name</p>'; } // Check for a price if (is_numeric($trimmed['price'])) { $price = mysqli_real_escape_string ($dbc, $trimmed['price']); } else { echo '<p class="error">Please enter a price</p>'; } // Check for a price if (is_numeric($trimmed['shipping_cost'])) { $ship = mysqli_real_escape_string ($dbc, $trimmed['shipping_cost']); } else { echo '<p class="error">Please enter a shipping cost</p>'; } // Check for paypal code: if ($_POST['paypal']) { $paypal = mysqli_real_escape_string ($dbc, $trimmed['paypal']); } else { echo '<p class="error">Please enter the paypal code</p>'; } // Check for product description: if ($_POST['product_des']) { $des = mysqli_real_escape_string ($dbc, $trimmed['product_des']); } else { echo '<p class="error">Please enter a product description</p>'; } // Check for product description: if ($_POST['cato_id']) { $cato_id = mysqli_real_escape_string ($dbc, $trimmed['cato_id']); } else { echo '<p class="error">Please Select a category</p>'; } if ($name && $price && $ship && $paypal && $des && $cato_id !== "") { // If everything's OK... $q = "UPDATE products SET name='$name', price='$price', ship='$ship', paypal='$paypal', descr='$des', cato='$cato_id' WHERE product_id='$id'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); echo '<p class="success"><em>The Product Information has Been Updated</em></p>'; } if($_POST['oldimage'] == 0){ // Check for an uploaded file: if (isset($_FILES['upload'])) { // Validate the type. Should be JPEG or PNG. $allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png'); if (in_array($_FILES['upload']['type'], $allowed)) { function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file $ext = findexts ($_FILES['upload']['name']); //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $timestamp = time(); //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $default_name = $timestamp."."; //This assigns the subdirectory you want to save into... make sure it exists! $target = TARGET; $image = "/photos/"; //This combines the directory, the random file name, and the extension $target = $target . $default_name.$ext; $image = $image . $default_name.$ext; // Move the file over. if (move_uploaded_file ($_FILES['upload']['tmp_name'], "$target")) { // Make the query: $q = "SELECT image FROM products WHERE product_id='$id' LIMIT 1"; $r = @mysqli_query ($dbc, $q); if(mysqli_affected_rows($dbc) == 1) {//Ran Ok ready to delete file $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $q = "UPDATE products SET image='$image' WHERE product_id='$id'"; $r = @mysqli_query ($dbc, $q); //Delete from file $myFile = DELPATH . $row[0]; if (file_exists($myFile)) { //Delete from file if(unlink($myFile)){ echo "<p class=\"success\">File: $row[0] has been successfully deleted</p>"; } } echo '<p class="success"><em>The Product Image has Been Changed</em></p>'; } } // End of move... IF. } else { // Invalid type. echo '<p class="error">Please upload a JPEG or PNG image.</p>'; } // Check for an error: if ($_FILES['upload']['error'] > 0) { echo '<p class="error">The file could not be uploaded because: <strong>'; // Print a message based upon the error. switch ($_FILES['upload']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting in php.ini.'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.'; break; case 3: print 'The file was only partially uploaded.'; break; case 4: print 'No file was uploaded.'; break; case 6: print 'No temporary folder was available.'; break; case 7: print 'Unable to write to the disk.'; break; case 8: print 'File upload stopped.'; break; default: print 'A system error occurred.'; break; } // End of switch. print '</strong></p>'; } // End of error IF. // Delete the file if it still exists: if (file_exists ($_FILES['upload']['tmp_name']) && is_file($_FILES['upload']['tmp_name']) ) { unlink ($_FILES['upload']['tmp_name']); } } // End of isset($_FILES['upload']) IF. } } I've been surfing the net recently for php cms system that I can implement into my clients websites, I've come across a really cool cms system pagelime. The cool thing about pagelime is that you can assign a css class to any div in the html document and pagelime can remotely read this html document and make that css div editable. then pagelime can save or generate the newly edited page. So... my question is how is this done? do they parse the html document via ftp into a php string then load it into a editor where the code is updated via ajax then remotely written back. Is there a industry word for this type of system? that I could use to find tuts on this topic? If someone is willing to point me in the right direction for more info then I will gladly share my finished cms system Thanks Danny Here's my code snippet. Code: [Select] if(preg_match("/^[ a-zA-Z1-42]+/", $_POST['name'])){ $name=$_POST['name']; $namer=$name; $result = mysql_query("select `resource` from resources where `resource_id` =" .$namer. "ORDER BY `resource_id` ASC "); echo "<br/>The following nations have " .$namer. " as a resource\n"; //-query the database table $sql="SELECT id, nation_id, ruler, resource1, resource2 FROM TS1 WHERE resource1 LIKE '%" . $name . "%' OR resource2 LIKE '%" . $name ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $ID=$row['id']; $Ruler=$row['ruler']; //-display the result of the array echo "<ul>\n"; echo "<li>" . "<a href=\"searcher.php?id=$ID\">" .$Ruler. "</a></li>\n"; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } } } Basically I have a number that's posted from a form field from another page to this page. It displays correctly on the results page but what i'm trying to do now is get that number to change based on the query at the top '' $result = mysql_query("select `resource` from resources where `resource_id` =" .$namer. "ORDER BY `resource_id` ASC "); " So if the number 3 (which is in the `resource_id` column) was posted it will display a result (which is in the `resource` column). But it just seems that the query isn't going through and it continues to display the 3 which was originally posted instead of changing 3 to a number in the database. I was thinking of performing a while loop so it just just displays the result of the query.. something like this: Code: [Select] $name=$_POST['name']; $namer=$name; $result = mysql_query("select `resource` from resources where `resource_id` =" .$namer. "ORDER BY `resource_id` ASC "); while($row = mysql_fetch_array($result)) { echo "<br/>The following nations have " . $row['resource'] . " as a resource\n"; }But that seems to have more problems as it doesn't display anything at all, not even the original number I had. I don't think it's a big problem.. Maybe something i've just overlooked? I have a form with dynamic text boxes that have dynamic names (i.e., TextBox1, TextBox2, etc.). How do I get those variables passed into php? I have tried and tried...even googled it, with no solid luck. Any help, immediately, would be so much appreciated. Hello, I'm working on a project that will let users access a website to view results. I getting via a FTP server CSV files. Files look like that (in French): "ARTICLES; BOISSONS 5.50% ; 1; ORANGINA ; 2.50; 2; PERRIER ; 5.00; 2; SCHWEPPES ; 5.00; ----------------------------------------; 5; BOISSONS 5.50% ; 12.50; RATIO %; 6.94; BOISSONS 19.60% ; 4; PELFORTH ; 10.00; 1; CHIVAS ; 7.00; 1; LIQUEUR ; 5.50; ----------------------------------------; 6; BOISSONS 19.60% ; 22.50; RATIO %; 12.50; RESTAURANT ; 1; BOUILLON POT AU FEU ; 7.00; 2; JAMBON D'AUVERGNE ; 20.00; 2; TERRINE PIED DE PORC; 16.00; 1; CASSOULET ; 20.00; 2; CONFIT DE CANARD ; 46.00; 1; CUISSE DE LAPIN ; 18.00; 1; MOURTAYROL ; 18.00; ----------------------------------------; 10; RESTAURANT ; 145.00; RATIO %; 80.56; ----------------------------------------; TOTAL ; ARTICLES ; 180.00; ------------------------------------------; ------------------------------------------; ------------------------------------------; REGLEMENTS; 2; ESPECES ; 109.50; 1; CARTE ; 70.50; ------------------------------------------; TOTAL ; REGLEMENTS; 180.00;" Basically, I'm trying to write code to "sort" each categorie (ARTICLES, REGLEMENTS....) Here is what I'd like to get: A B C D E ARTICLES; BOISSONS 5.50% ; 1; ORANGINA ; 2; PERRIER ; 2; SCHWEPPES ; BOISSONS 19.60% ; 4; PELFORTH ; 1; CHIVAS ; 1; LIQUEUR ; RESTAURANT ; 1; BOUILLON POT AU FEU ; 2; JAMBON DE DINDE ; 2; TERRINE PIED DE PORC; 1; CASSOULET ; 2; CONFIT DE CANARD ; 1; CUISSE DE LAPIN ; 1; MOURTAYROL ; TOTAL ; 5; BOISSONS 5.50% ; 12.50; 6; BOISSONS 19.60% ; 22.50; 10; RESTAURANT ; 145.00; REGLEMENTS; 2; ESPECES ; 109.50; 1; CARTE ; 70.50; A, B, D only names C, E only numbers These datas will be used to generate pie charts Thanks for your attention Hello Forum, please can someone help me solve this error in the code below, thanks Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\XAMPP\xampp\htdocs\testingSite\addtobasket.php on line 10 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\XAMPP\xampp\htdocs\testingSite\addtobasket.php on line 11 <?php session_start(); require("db.php"); require("function.php"); $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); $prodsql = "SELECT * FROM products WHERE id =" .$_GET['id'] . "'"; $prodres = mysql_query($prodsql); $numrows = mysql_num_rows($prodres); $prodrow = mysql_fetch_assoc($prodres); if($numrows == 0) { header("Location: ". $config_basedir); } else { if($_POST['submit']) { if($_SESSION['SESS_ORDERNUM']) { $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] . "," . $_GET['id'] . "," . $_POST['amountBox'] .")"; mysql_query($itemsql); } else { if($_SESSION['SESSION_LOGGEDIN']) { $sql = "INSERT INTO orders(customer_id, registered, date) VALUES (" . $_SESSION['SESS_USERID'] . ", 1, NOW())"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] .",". $_GET['id'] . "," . $_POST['amountBox'] . ")"; mysql_query($itemsql); } else { $sql = "INSERT INTO orders(registered, date, session) VALUES(" ."o, NOW(),'" . session_id() . "')"; mysql_query($sql); session_registered("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES(" . $_SESSION['SESS_ORDERNUM'] . "," .$_GET['id'] . "," . $_POST['amountBox'] . ")"; mysql_query($itemsql); } } $totalprice = $prodrow['price'] * $_POST['amountBox']; $updsql = "UPDATE orders SET total + ". $totalprice . " WHERE id = " . $_SESSION['SESS_ORDERNUM'] . ";"; mysql_query($updres); header("Location: " . $config_basedir . "showcart.php"); } else { require("header.php"); echo "<form action='addtobasket.php?id=" .$_GET['id'] . "' method='POST'>"; echo "<table cellpadding='10'>"; echo "<tr>"; if(empty($prodrow['image'])) { echo "<td><img src='./images.dummy.jpg' width='50' alt='" . $prodrow['name'] . "'></td>"; } else { echo "<td><img src=' ./images/" . $prodrow['image'] . "' width='50' alt='" . $prodrow['name'] . "'></td>"; } echo "<td>" . $prodrow['name'] ."</td>"; echo "<td>Select Quantity <select name='amountBox'>"; for($i=1;$i<=100;$i++) { echo "<option>" . $i . "</option>"; } echo "</select></td>"; echo "<td><strong>£" . sprintf('%.2f', $prodrow['price']) . "</strong></td>"; echo "<td><input type='submit' name='submit' value='Add to basket'></td>"; echo "</tr>"; echo "</table>"; echo "<form>"; } } require("footer.php"); ?> okay so i need this same logo to be on the other page..how do i do it.. this is code of the logo page.. Code: [Select] <? if(isset($_GET[ttid])) { $ttid = $_GET[ttid]; } $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query = "select master_event.* , (DATE_FORMAT(event_datefrom, '%d %M %Y')) as datefrom, (DATE_FORMAT(event_dateto, '%d %M %Y')) as dateto, ucase(event_name) as eventname from master_event where master_event.event_id = '$ttid '"; $result=mysql_query($query); while($row = mysql_fetch_array($result)){ $eventname = $row['eventname']; $eventdesc = $row['event_desc']; //$companydescription = $row['company_description']; $eventvenue = $row['event_venue']; $eventfee = $row['event_fee']; $datefrom = $row['datefrom']; $dateto = $row['dateto']; echo "<font color='#000000' face='arial' ><b> $eventname </b> </font> <br>"; echo "<font color='#000000' face='arial' ><i>Date</i> : $datefrom - $dateto <br>"; echo "<i>Venue</i> : $eventvenue <br>"; $querypstype = "SELECT DISTINCT master_pstype.pstype_id, pstype_desc FROM master_pstype INNER JOIN master_psevent ON master_psevent.pstype_id= master_pstype.pstype_id where master_psevent.event_id = '$ttid' ORDER BY pstype_order"; $resultpstype=mysql_query($querypstype); while($rowpstype = mysql_fetch_array($resultpstype)){ $pstypeid = $rowpstype['pstype_id']; $pstypedesc = $rowpstype['pstype_desc']; echo "<br><font color='#8B3A3A' size='1' face='georgia' ><b><i>$pstypedesc</i></b></font> <br>"; $queryps = "SELECT master_psevent.*, pstype_desc, company_name, company_link, company_description, logo_filename FROM master_psevent LEFT JOIN master_pstype ON master_psevent.pstype_id = master_pstype.pstype_id LEFT JOIN master_ps ON master_ps.ps_id = master_psevent.ps_id WHERE master_psevent.event_id = '$ttid' and master_pstype.pstype_id= '$pstypeid' ORDER BY pstype_desc,company_name "; echo $queryps; $resultps=mysql_query($queryps); while($rowps = mysql_fetch_array($resultps)){ $companyname = $rowps['company_name']; $companyid = $rowps['ps_id']; $companylinkori = $rowps['company_link']; $companydescription = $rowps['company_description']; $logopath = $rowps['logo_filename']; $describelink = "index.php?view=describe&ttid=$ttid&pstypeid=$pstypeid&psid=$companyid"; if(!empty($companydescription)){ echo "<a href=\"$describelink\" target=\"_blank\"><img src=".$logo_dir."/".$logopath." width=\"15%\" border=\"0\"></a>"; } else { echo "<a href=\"$describelink\" target=\"_blank\"><img src=".$logo_dir."/".$logopath." width=\"15%\" border=\"0\"></a>"; } } } } ?> i need to put the logo script on this page without removing other data..just wanna add the logo in it..where do i alter? Code: [Select] <? $monthname=$_POST['month']; if (isset($_GET['np'])){ $num_pages=$_GET['np']; } else { if($searchtype == 'yes') if ($monthname=="All" || $monthname=="") { $query = "SELECT count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom desc"; }else { $query = "SELECT count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom desc"; } else if ($monthname=="All" || $monthname=="") { $query = "Select count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom desc"; }else { $query = "Select count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom desc"; } $result=mysql_query($query); $row=mysql_fetch_array($result, MYSQL_NUM); $num_records=$row[0]; if ($num_records > $displayhome){ $num_pages=ceil($num_records/$displayhome); } else { $num_pages=1; } } if (isset($_GET['s'])){ $start=$_GET['s']; } else { $start=0; } if ($monthname=="All" || $monthname=="") { $query = "SELECT master_event.*,master_type.type_name, DATE_FORMAT(event_datefrom, '%d %b %y') as datefrom, DATE_FORMAT(event_dateto, '%d %b %y') as dateto, event_venue, (event_name) as eventname FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom asc LIMIT $start, $displayhome"; }else { $query = "SELECT master_event.*,master_type.type_name, DATE_FORMAT(event_datefrom, '%d %b %y') as datefrom, DATE_FORMAT(event_dateto, '%d %b %y') as dateto, event_venue, (event_name) as eventname FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom asc LIMIT $start, $displayhome"; } $result = mysql_query($query); $bg='#e5e5e5'; while($row = mysql_fetch_array($result)){ $eventid = $row['event_id']; $eventname = str_replace("", "", $row['eventname']); $eventdatefrom = $row['datefrom']; $eventdateto = $row['dateto']; $event_venue = $row['event_venue']; $event_desc = $row['event_desc']; $speakerlist = $row['speakerlist']; $showline1 = ""; $showpros =""; $showline2 = ""; $showreg =""; $showline3 = ""; $showps =""; $showline4 = ""; $showtestimonial =""; $showline5 = ""; $showsp =""; $showline6 = ""; $showsl =""; if ($eventdatefrom ==$eventdateto) { $eventdate = $eventdatefrom; } else { $eventdate = $eventdatefrom . " - " . $eventdateto; } $querypros="select count(*) as proscount from master_prospectus where event_id ='$eventid' "; $resultpros = mysql_query($querypros); while($rowpros = mysql_fetch_array($resultpros)){ $proscount = $rowpros['proscount']; if ($proscount > 0) { $showline1 = "|"; $showpros ="Request Brochure"; } } $queryreg="select (CASE WHEN event_dateto >= NOW() THEN 'valid' ELSE 'invalid' END) AS validreg from master_event where event_id ='$eventid' "; $resultreg = mysql_query($queryreg); while($rowreg = mysql_fetch_array($resultreg)){ $validreg = $rowreg['validreg']; if ($validreg == "valid") { $showline2 = "|"; $showreg ="Online Registration"; } } $queryps="select count(*) as pscount from master_psevent where event_id ='$eventid' "; $resultps = mysql_query($queryps); while($rowps = mysql_fetch_array($resultps)){ $pscount = $rowps['pscount']; if ($pscount > 0) { $showline3 = "|"; $showps ="Partner & Sponsor"; } } $querytesm="select count(*) as tesmcount from master_testimonial where event_id ='$eventid' "; $resulttesm = mysql_query($querytesm); while($rowtesm = mysql_fetch_array($resulttesm)){ $tesmcount = $rowtesm['tesmcount']; if ($tesmcount > 0) { $showline4 = "|"; $showtestimonial ="Testimonial"; } } $querysp="select count(*) as spcount from master_speakernote where event_id ='$eventid' "; $resultsp = mysql_query($querysp); while($rowsp = mysql_fetch_array($resultsp)){ $spcount = $rowsp['spcount']; if ($spcount > 0) { $showline5 = "|"; $showsp ="Speaker Notes"; } } if ($speakerlist <> '') { $showline6 = "|"; $showsl ="Speaker List"; } echo "<tr><p style=\"font-size:small;\"> <td width='' ><img src='images/search.png' alt='tooltips' ></img> <a href='index.php?view=event&content=tips&ttid=$eventid' title ='$eventname' class=\"fancybox fancybox.iframe\" style=\"color:#104E8B;text-decoration: none; \" ><strong><font size='2' face='Segoe UI' >$eventname</font></strong></a><br> <font color='#000000' size='2' face='arial' >Date : $eventdate <br> Venue : $event_venue<br></font> <table style=\"text-align: left; width: 400px; height: 92px;\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\"> <tbody> <tr> <td></td> <td style=\"text-align: justify; color: #000000;\"> <font color='#000000' size='2' face='arial' > $event_desc</font></td> <td></td> </tr> </tbody> </table> <font color='#919191' size='1' face='arial' ><b> <a href='index.php?view=prospectus®rq=$eventid' title ='Request Brochure...' >$showpros</a> <b>$showline1</b> <a href='index.php?view=registration®rq=$eventid' title ='Online Registration...' > $showreg </a> <b>$showline2</b> <a href='index.php?view=event&content=psevent&ttid=$eventid' title ='Sponsor & Partner...' class='fancybox fancybox.iframe' >$showps</a> <b>$showline3</b> <a href='index.php?view=event&content=tesm&ttid=$eventid' title ='Testimonial...' class='fancybox fancybox.iframe' >$showtestimonial</a> <b>$showline4</b> <a href='index.php?view=spl&splid=$eventid' > $showsp</a><b>$showline5</b> <a href='index.php?view=event&content=speaker&ttid=$eventid' title ='$eventname' class='fancybox fancybox.iframe' > $showsl</a></font><br><br></td> </p></tr></b></font> "; } if ($eventid=="") { echo "No Records Found."; } echo "<td><p style=\"font-size:1;\">"; echo "<br>"; if ($num_pages > 1) { $current_page = ($start/$displayhome) + 1; if ($current_page != 1) { echo '<a href="index.php?view=home&content=list&s=' . ($start - $displayhome) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">Previous</a> ';} for ($i = 1; $i <= $num_pages; $i++) { if ($i != $current_page) { echo '<a href="index.php?view=home&content=list&s=' . (($displayhome * ($i - 1))) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">' . $i . '</a> '; } else { echo '<font face="arial" size="2">'; echo $i . '</font> ';} } if ($current_page != $num_pages) { echo '<a href="index.php?view=home&content=list&s=' . ($start + $displayhome) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">Next</a>';} } echo "</p></td>"; ?> </tr> </div> </form> Hello: I have a small chunck of code that dosplays data depending on which PlayerID is selected. Like so: Code: [Select] <?php $myvar = $_REQUEST['PlayerID']; ?> ... <?php if ( $myvar == "1" ) { echo "Your name is Tina"; } elseif ( $myvar == "2" ) { echo "Your name is Sue"; } else { echo "Your name is Jill"; } ?> This works fine - no errors - but I am use to ASP and using an "End If" after "Else" ... Is this not needed in PHP? Thanks. Hi I am new here and I am not a PHP specialist. I run a website (www.theowl.com) and last week I upgraded from PHP 4.X to 5.x on the Namesco server. Everything worked except one thing.... I commissioned an EDI link to DHL, and this was setup using PHP FTP. This system works automatically plus I have a manual link to trigger orders. Since upgrading PHP the automatic process has stopped but the manual process still works fine. Would anybody be able to help. I have attached what I think is the correct file. I am happy to pay for peoples time. i have a piece of code which subtracts credits every time a button is clicked. the original code works fine. I have since added a bonus_credit column, where i want it to function like this. if buy_credit = 0 and bonus_credit>0 then subtract from the bonus credit, but still do everything else its supposed to do.. here is the original code i had $selRes=mysql_query("SELECT buy_credit from user where id='".$hb_id."' and buy_credit>0"); if(mysql_affected_rows()>0) { $b_comm=0; $bc_updqry=mysql_query("UPDATE user set buy_credit=buy_credit-1 where id='".$hb_id."'"); $updqry=mysql_query("UPDATE cars set b_fee_paid_status='1' where id='".$aid."'"); } here is my modified code, but it doesn't seem to subtract from buy_credit if buy_credit is >0.. it should only kick in the bonus_credit usage if buy_credit is 0 $selRes=mysql_query("SELECT buy_credit,bonus_credit from user where id='".$hb_id."' and buy_credit>0 OR bonus_credit>0"); if(mysql_affected_rows()>0) { $b_comm=0; if($selRes['buy_credit']!=0) { $bc_updqry=mysql_query("UPDATE user set buy_credit=buy_credit-1 where id='".$hb_id."'"); } else { $bc_updqry=mysql_query("UPDATE user set bonus_credit=bonus_credit-1 where id='".$hb_id."'"); } $updqry=mysql_query("UPDATE cars set b_fee_paid_status='1' where id='".$aid."'"); } your help is appreciated. Hello all,
Am trying to get the answers of a survey from my DB and display the percentage.. Everything am trying seems not to be working. please what am i doing wrong.
<? $question_query = "SELECT * FROM ".$tblprefix."question WHERE category = 'Service Availability' and section = 'Information Technology Services'"; $rs = $db->Execute($question_query); $all_the_time = array(); $most_of_the_time = array(); $sometimes = array(); $never = array(); while (!$rs->EOF) { $question_id = $rs->fields['question_id']; $question_query1 = "SELECT * FROM ".$tblprefix."user_answer, ".$tblprefix."question WHERE ".$tblprefix."user_answer.question_id = ".$tblprefix."question.question_id"; $rs1 = $db->Execute($question_query1); $answer_id = $rs1->fields['user_answer_id']; $question_query2 = "SELECT * FROM ".$tblprefix."answer WHERE answer_id = '$answer_id'"; $rs2 = $db->Execute($question_query2); $answer = $rs2->fields['answer']; if($answer == 'All the time') { array_push($all_the_time,'1'); } else if ($answer == 'Most of the time') { array_push($most_of_the_time,'1'); } else if ($answer == 'Sometimes') { array_push($sometimes,'1'); } else if($answer == 'Never') { array_push($never,'1'); } $rs->MoveNext(); } $count_all_of_time = count($all_the_time); $count_most_of_time= count($most_of_the_time); $count_sometimes = count($sometimes); $count_never = count($never); ?> <table border="0" class="question_answer_table"> <tr> <td><strong>Service Availability</strong></td> </tr> </table> <table border="0" class="question_answer_table"> <tr> <td style="width:120px;">All of Time</td> <td style="width:70px;"><?=round($count_all_of_time/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Most of Time</td> <td><?=round($count_most_of_time/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Sometimes</td> <td><?=round($count_sometimes/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Never</td> <td><?=round($count_never/$totaluser*100,2) .'%'?></td> </tr> </table>Only one of the field is displaying an output. the rest are not. thanks in advance Hello everyone,
I run a small url shorting service.
I have bought the script and everything which short long urls. And i want to use a php code in one of the pages.
Let me explain you in detail first.
My site is https://786.pw and user goes there and enter the long url and the short url becomes something like https://786.pw/shorturl ( for example)
Now when this short url which is https://786.pw/shorturl is hit the user is redirected to the original long url. And thats how it is supposed to work.
But in between i have the option to show a splash page which can be a advertisement or a timer or anything "
The code of splash.php is :-
<?php defined("APP") or die() // Media Page ?> <?php include_once("analyticstracking.php") ?> <section> <div class="container splash"> <?php echo $this->ads(728,FALSE) ?> <div class="row"> <div class="col-md-4 thumb"> <div class="panel panel-dark panel-body"> <img src="<?php echo $url->short ?>/i"> </div> </div> <div class="col-md-8"> <div class="panel panel-default panel-body"> <h2> <?php if (!empty($url->meta_title)): ?> <?php echo $url->meta_title ?> <?php else: ?> <?php echo e("You are about to be redirected to another page.") ?> <?php endif ?> </h2> <p class="description"> <?php if (!empty($url->meta_description)): ?> <?php echo $url->meta_description ?> <?php endif ?> </p> <br> <div class="row"> <div class="col-sm-6"> <a href="<?php echo $this->config["url"] ?>/?r=<?php echo base64_encode($url->url) ?>" class="btn btn-primary btn-block redirect" rel="nofollow"><?php echo e("Redirect me"); ?></a> </div> <div class="col-sm-6"> <a href="<?php echo $this->config["url"] ?>" class="btn btn-default btn-block" rel="nofollow"><?php echo e("Take me to your homepage") ?></a></a> </div> </div> <hr> <p class="disclaimer"> <?php echo e("You are about to be redirected to another page. We are not responsible for the content of that page or the consequences it may have on you.") ?> </p> </div> </div> </div> </div> </section>Now, I want to add solve media php script in it. Which means any user who is using our url shortner service needs to complete the captcha before he can be finally directed to the destination url. The script supports solvemedia captcha solving. I spoke to the creator of this script and he told me this. "You will need to have some basic php knowledge to achieve this. Ok, first let me say hello, and thanks for viewing this. I do not know very much about PHP at all, and therein lies the problem... I was editing a php document for my friends website. All I was doing was adding a line of code so that his site would include a favicon. I right-clicked on the website and viewed his source, and copied all the code into notepad, added the string of code for the favicon, and uploaded it to his FTP. Unfortunately when I did that I overwrote some of the PHP code I believe...it didn't copy that when I viewed the site source. I want to make it right for my friend and fix his website but I have NOOOO idea what to do... So I have turned to this forum for help... This is my friends website: thcklan . com The "recent topics" and "recent posts" at the top, the "hackers banned from our servers," and the "announcements" no longer update properly... It's like they are frozen at the state they were in when I copied the site's source code... I feel like an utter jack arse for ruining my buds front page. Please, I am asking you from deep within my heart, HELP ME, point me in the right direction, or guide me in some way to make it right to my good friend and fix his site! |