PHP - Easy One - What Is The Symbol For Or?
Easy One - What is the symbol for or?
Example: && = and, right? What is 'or'? Similar TutorialsWhat is the & symbol used for I have seen it in function setname(&$name){ $this->name =& $name; } Thanks I have looked on google and can't find it as i don't know what it is called. thanks Hello, Im getting a name from the url, for instance, index.php?name=C.-and-G The "and" is then converted to a & symbol and dashes converted to spaces. This then uses the new name "C. & G" to select a record from mysql. However, it does not recognise the & symbol, the name in mysql is "C. & G" but returns 0 records. Any ideas? Thanks! I'm a little confused exactly on how using this } works going to be hard to explain what im having problems with. I'm using JEdit for my editor and I notice if I click on one of these { it will put a box around where it ends there is 4 } at the bottom of the code by them selfs "on their own lines" and 2 in the middle by them selfs "on their own lines how does the code know which ones belong to which { appreicate any help in helping me understand this thanks this code is from a tutor online Code: [Select] <? include_once("connect.php"); ?> <html> <body> <?php if(isset($_POST['Login'])) { if(!preg_match('/^[A-Za-z0-9]{5,20}$/',$_POST['Username'])){ // before we fetch anything from the database we want to see if the user name is in the correct format. echo "Invalid Username."; }else{ $query = "SELECT password,id,login_ip FROM users WHERE name='".mysql_real_escape_string($_POST['Username'])."'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); // Search the database and get the password, id, and login ip that belongs to the name in the username field. if(empty($row['id'])){ // check if the id exist and it isn't blank. echo "Account doesn't exist."; }else{ if(md5($_POST['password']) != $row['password']){ // if the account does exist this is matching the password with the password typed in the password field. notice to read the md5 hash we need to use the md5 function. echo "Your password is incorrect."; }else{ if(empty($row['login_ip'])){ // checks to see if the login ip has an ip already $row['login_ip'] = $_SERVER['REMOTE_ADDR']; }else{ $ip_information = explode("-", $row['login_ip']); // if the ip is different from the ip that is on the database it will store it if (in_array($_SERVER['REMOTE_ADDR'], $ip_information)) { $row['login_ip'] = $row['login_ip']; }else{ $row['login_ip'] = $row['login_ip']."-".$_SERVER['REMOTE_ADDR']; } } $_SESSION['user_id'] = $row['id'];// this line of code is very important. This saves the user id in the php session so we can use it in the game to display information to the user. $result = mysql_query("UPDATE users SET userip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',login_ip='".mysql_real_escape_string($row['login_ip'])."' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'") or die(mysql_error()); // to test that the session saves well we are using the sessions id update the database with the ip information we have received. header("Location: Sample.php"); // this header redirects me to the Sample.php i made earlier } } } } ?> <form id="form1" name="form1" method="post" action=""><center> GAME LOGIN <br /> <br /> Username: <input type="text" name="Username" id="Username" /> <br /> <br /> Password: <input type="password" name="password" id="password" /> <br /> <br /> <input type="submit" name="Login" id="Login" value="Login" /> </center> </form> </body> </html> I am running php 5.3.2 on my local dev and on the server I am running php 5.2.5. In my log files I keep getting deprecated messages like: PHP Deprecated: Assigning the return value of new by reference is deprecated in /Users/xxx/dev/git/xxx/cake/dispatcher.php on line 677 Can I just delete & to get rid of this message or will that hose the script locally and on the server? I believe that php 5+ passes all objects as reference. Thanks Hi, I'm looking through some code I have for setting up a rating system. It was a free open source code, which I need to change to work for my own site. I have it working, but I am now just looking through the code to try and understand it, and for the most part, I do. There is one part I am not familiar with, if somebody could help me please? Values involved; $current_rating = total rate value of votes $count = total number of votes cast Problem I have is the @ symbol here $rating=@number_format($current_rating/$count, 1); Does it format it to decimal places or something like that? It's probably something simple I know, but I am a relative newb. Thanks. Code: [Select] $query = "LOWER(name)="$tabB"; on my forums, speakwhatsreal.com new message page, let's say somone on my site has the name "$tabB" how do i make the above query work so it selects a username with the $ symbol in it? because with that query it's linked to Code: [Select] $DB->query("SELECT name, id, mgroup, language, email FROM ibf_members WHERE ".$query); $to_member = $DB->fetch_row(); if (empty($to_member['id'])) { $this->send_form(0, $ibforums->lang['err_no_such_member']); return; } pretty much says no results.. lol any help? This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=322426.0 Trying to echo a string that contains a hash symbol. Instead of getting a hash symbol, I get %29. The code I am using is pretty basic -->$idx="#" . $idxA;<--, but as stated, when I echo $idx, it comes out as %29. (All of this is part of a form, get, attempting to pass a bookmark to the receiving program. Thoughts? Code: [Select] $mystring = "|Signature"; $findme = '|'; $pos = strpos($mystring, $findme); echo $pos; echo's 0 supposed to echo out 1....? why not work thanks How can I enable it to check for Code: [Select] | using strpos? What does it mean Like.. !@file_get_contents('url'); or.. !file_get_contents or @file_get_contents So I have a simple query that adds a text record into a MySQL database table. It works great with exception of one thing. I noticed that if I have "&" symbol in my paragraph, the text after that symbol won't be inserted into the table. The text before that symbol will insert fine. It seems to be doing that only with & symbol; other symbols insert and show up fine. can anyone tell me why this is happening? hello i can't figure out how to modify a value from assoc array so with each recursion to add additional string to his: for example i have attribute=""; then call recursive function and i try to modify its value by concatenating "0"; or "1"; on the next loop to add again "0" or "1"; Hi i want to match $ symbol from the string. I am using the following script Code: [Select] $str="ckj"; if(preg_match("/^$/",$str)) { echo "Dollar is found"; } else { echo "Not Found"; } Its not working fine. Can anyone help me out please. So i'm having some sort of an issue. what i'm trying to do is to get the name from an URL using GET that includes the "&" symbol. I have a link and that link looks like this: name_of_company_&_member. What im trying to do is to get that whole line using Get and echoing on a page. The problem is that the line cuts off after "company_" because it reads the & symbol as something different. Does anyone know how i can be able to retrieve the whole line including everything after the & symbol? i tried using the special character "%26" but i still get the same result. ob_start(); include('file.php'); $content = ob_get_clean(); ok so this is the code i found for adding a file to a variable.. now how would i use it in term of this: <?php $id = NULL; if(isset($_GET['id']) && $_GET['id'] == "1"){ $id = 'Marc'; } else if(isset($_GET['id']) && $_GET['id'] == "2"){ $id = 'Glenn'; } else if(isset($_GET['id']) && $_GET['id'] == "3"){ $id = 'Nathan'; } else if(isset($_GET['id']) && $_GET['id'] == "4"){ $id = 'Scott'; } ?> ok so the get variable checks to see whose id youve requested. then when for example id = 4 i want to display an include file somewhere else on the page so i would use.. <?php echo $id; ?> now insted of it being "nathan" i want it to be a file i didnt really understand the first code i found OK below is my code. the values for $row['state'] are in this format "AL - Alabama" its got the space in it. Code: [Select] while($row = mysql_fetch_array($result)) { echo "<option value=" . $row['state'] . '">' . $row['state']; } ?> When i run the script it outputs HTML as this Code: [Select] <option value="AL" -="" alabama"="">AL - Alabama</option> As you can see at the space it terminates and puts the " in. Im assuming this is a rookie programming mistake. Please help, Justin Right now I'm working on a simple register form and I have included the theme. I set up a div and positioned the div below the register form to output any error in red text. If I were to use code like this if(empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email']) || empty($_POST['Veremail'])){ $required_info = "All three fields are required to continue!"; } It will not work, because I don't have a die(); or end(); function, so it will display: " All three fields are required to continue! and You have been successfully registered! " BUT IT'S IN THE CORRECT PLACE UNDER THE FORM WHERE I PLACED THE DIV. So I made this change if(empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email']) || empty($_POST['Veremail'])){ $required_info = die("All three fields are required to continue!"); } and it worked fine, but now, the words are not positioned under the form, but at the bottom of the page, I'm wondering how I would end that script, but align the text so it displays underneath the form, and not at the bottom of the page? If you don't understand ask me please. I am trying to send an html file (with .js formatting) to the browser from within a PHP script. The .js formatting is not being interpreted and so the result in the browser is less than impressive. Why can't I make a call, in PHP, to a url and have the results from that call directed to the browser? |