Assign To Variable
I am trying to take data from the database and assign it to a variable but i'm not sure how this is the code ive been trying
$sql = "SELECT Name FROM Names WHERE Name = 'Peter'";
while($row = @mysql_fetch_array($sql))
{
$var == $row['Name'];
}
View Complete Forum Thread with Replies
Related Forum Messages:
Assign Value To Variable
Is there any way I can use a function to create a variable and assign a value to it? I have a Perl script that returns some LDAP information: sn=Shore givenname=Mike logintime=20041008153445Z logindisabled=FALSE Instead of parsing this text and assigning the values, I was wondering if a function exists where I can pass a variable name and a value, and the variable would be created. ie. somefunc("sn", "Shore") Would create the variable $sn and assign the value "Shore" to it.
View Replies !
Is It Possible To Assign A Whole Function Or Block To A Variable ???
Is it possible to assign a whole function or block to a variable ??? eg. <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <? if (db_num_rows($qid_p) == 0) { ?> <li>No <? } ?> <? while ($prod = db_fetch_object($qid_p)) { ?> <p><b><a href="product_details.php?id=<?=$prod->id?>"><? pv($prod->name) ?></a></b> <br><? pv($prod->description) ?> <br>$<? pv($prod->price) ?> <br>[<a href="cart_add.php?id=<?=$prod->id?>">+ Add to Cart</a>] <? } ?> How to assign this code to a unique variable ???
View Replies !
Assign Function Output To Variable??
I've found some references to this topic at : http://forums.devshed.com/showthrea...ion+to+variable but it does not seem to be working for me. here's a snippet... <? PHP function listPeople ($getArray) { foreach ( $getArray as $val ) { echo "$val, "; } } $foo = listPeople($splitDirector); ?> The function works, and as you can see i'm simply trying to assign the output of the function to $foo. But instead, the output is written to the page where I assign it... like a print or echo statement, and the variable $foo is empty.
View Replies !
Ways To Assign A Value To A Session Variable.
I am wandering which way to assign a value to a session variable exist. Which of the following examples will work. Example #1: session_start(); session_register("ex"); $ex = 2.0; Example #2: In first.php: session_start(); session_register("ex"); In second.php: $ex = 2.0; Example #3: In first.php: session_start();...
View Replies !
Assign Variable From Database Field
Is there a way to assign a variable from a database field? I'm thinking along the lines of $make = $row_rsList['make']; $model = $row_rsList['model']; then they'll switch out based on my SQL WHERE statement. This valid syntax?
View Replies !
Assign Userid To A Session Variable
When a user logs into my system, i assign their userid to a session variable [php] $_SESSION['userid'] = $myrow[0]; [php] and then a user logs out, i do the following [php] $_SESSION['userid'] = '' session_write_close(); [php] so, when a user clicks on a link to a page they should only see when logged in, i do the following test [php] if (isset($_SESSION['userid'])) { header('Location: members.php3'); } [php] but the logout does not seem to work for some reason? userid still seems to be set after running the logout script, any ideas? am i doing something silly?
View Replies !
Assign A New Value To A Variable Passed From An Html Form
I'm trying to assign a new value to a variable passed from an html form to a php3 script. I'm using an if statement to evaluate variable 3 to see if it is equal to a specific string, if it is I'm reassigning variable 2 to be variable2+variable 3. if ($question3!="select days") { $question2=$question2+$question3; } This is the statement. It keeps giving me a parse error and I can't seem to find the right documentation to show me how to combine two string variables.
View Replies !
Multi-Dimensional Arrays - Assign Variable
It's a simple question, but I'm just not getting it. I have two files: <?php $precinct = array ( array ( number=>2324, centerlat=>-122.31705665588379, centerlong=>47.710367959402525, etc... <?php include ("precinctdata.php"); $filename = $_GET['id']; $number = $precinct[filename-1][number]; etc... I want to assign the value of "2324" to the variable $number. I've done this with arrays that start with number=>1, 2, 3, etc., but not successfully with specific values. What am I missing?
View Replies !
Assign MySQL Function Result To PHP Variable
I know to use: mysql_fetch_row($result) to convert a row from a SQL query result set into an array for use with PHP. but in the case of SQL queries that return one value, such as calls to MySQL functions, is there another PHP mysql api function I should use. For example, right now I use a "workaround" technique from PHPBuilder: $result=mysql_query("SELECT COUNT(*) FROM tablename"); list($numrows)=mysql_fetch_row($result); Rather than using this "workaround" code is there a way to simply assign the result of the MySQL function query to a variable. $result=mysql_query("SELECT COUNT(*) FROM tablename"); $numrows=mysteryfunction($result);
View Replies !
Assign Variable To A Block Of Html Code
Is it possible to assign variable to a block of html code? Something like this : $myblokvar = "<table width="487" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="487" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="images/bartitle_login.gif " alt="Login" width="475"...
View Replies !
Assign Variable Name As Variable
I want to be able to create a foreach loop that will go through all the intended POST variables and then assign it as a standard variable. For example, I want to have $username = $_POST['username'] without even knowing username exists in the context of the foreach loop. Code:
View Replies !
Cannot Re-assign $this ...
I'm one more guy having the cannot re-assign $this problem. someone left a php4 file here containing the lines |function linkbar() |{ |if(func_num_args() == 1) |{ |$this = func_get_arg(0); |return; } ... |} inside a php4 class definition. func_get_arg(0) in this case delivers an object - working fine in php4. I struggled a bit with the & referencing (while not really understanding it and the problem) but gave up. how must I modify the code to get it to work in php5?
View Replies !
PHP 5 Re-assign $this PROBLEM
Just a quickie, in case it's been covered, like a million times or something. I'm self taught, and thought I was being pretty clever when building a "messaging" class. The idea was to abstract "html email", "text email" and "sms message" up a layer into a "message". To get a message started, I call on something like this: $msg = new Message("sms"); Message (which re-assigns the $this variable) then looks something like this: class Message{ var $message_hash; var $message_path;//this can be changed, in case stuff is moved in future... function ryan_Message($type=""){//starts the whole thing switch($type){ case "html"://this means an html email include_once("HtmlMessage.php"); $this = new HtmlMessage(); break; case "text"://this means a text mail include_once("TextMessage.php"); $this = new TextMessage(); break; case "sms"://this means an sms message include_once("SmsMessage.php"); $this = new SmsMessage(); break; }// end switch }// end function }// end class Each class has methods that are named the same, but act a little differently, so, basically, I can use the same set of commands to compose a message and send it, regardless of what type of message it is. Things work fantastically under php4, but I know that when I swap over to php5, it's going to throw a hissy fit, because reassigning $this is not allowed. Aside from going around the Message class, and just starting messages of a particular type from scratch: Is there some sort of cunning retro-fit I could do to the Message class, so I don't have to trawl through thousands of lines of code?
View Replies !
Assign Value On Click
is there a way to change the value of a variable when a hyperlink is clicked? like im include()ing a variable $content. and when you click it changes from URL to links or whatever?
View Replies !
Assign Value To The Link
I am creating a order-online application. I create some links in my html file. And in my table that I created by mySQL, there are some fields including picture_id, picture_name. What I want is to assign the picture_id to the link so that the picture_name will be selected (using mySQL) when the link was clicked. Can someone tell me how to write PHP code to assign the picture_id to the link?
View Replies !
Assign Include
if I can assign the output of an included file like include("file.php"); to a variable? I tried $content = include("file.php"); but it does actually include the file. I want the output kept in the variable and not be displayed, because I plan to use the variable later with a template engine.
View Replies !
Assign All The Values
How do i assign all my values of a row: I found the following: is it a good way to do: Code: $row = $rs->GetRowAssoc(false); Code: $strSQL = Select * from users where id_user=ཊ' $rs = $dbconn->Execute($strSQL); $row = $rs->GetRowAssoc(false); $data["login"] = $row["login"]; $data["fname"] = $row["fname"]; $data["sname"] = $row["sname"]; $data["country"] = $row["country"]; $data["city"] = $row["city"];
View Replies !
How Do You Assign A Various Number Of Variables?
I'm struggeling with a small search engine here. I'm trying to put everything together myself, but I have a problem. I've made a small form where search-words can be entered. This string is put into a variable $search. Then I've split this string up in pieces using the SPLIT command. something like this: list ($one, $two, $three) = split ('[ ]', $search); This works very nicely, but there is only one small problem. I can't possibly know how many search words will be used. It could be only one, but it could very be 10 or more (although unlikely). I thought about creating 10 variables, and in case they use less, they are just blank, but then if I use a OR function between these empty variables, the complete database (MySQL by the way) is called for. I don't know if you're getting the picture, but I want to know how I can assing a number of variables not knowing the amount in advance.
View Replies !
Assign Japanese String To Var
Following code contains japanese string that is assigned to variable $str. code ============= <?php $str = "$B%0%C%I%P%$%T%+%=(B"; ?> ========= When i am executing above program it gives me error as following. Parse error: parse error, unexpected $ in /var/www/html/bhavin/mohla1.2.2/b.php on line 3 Do anybody have solution for the above problem. How can i assign above japanese string($B%0%C%I%P%$%T%+%=(B) to variable without error.
View Replies !
Trying To Assign Number To Image..
I am working on a countdown script that will display the number of days to go to an event. I am after a graphical version. I have the code working that displays the amount of days to go to the event but I now want to display that number as a graphic. Whats the way of parsing the varible with "19" in it to make up a graphic? I have graphics for digits 0 - 9 made. Do you use some sort of array?
View Replies !
Extract 5 Rows Assign Name
I want to extract the last 5 thumbnail names added into my products table and assign each one a variable, for example: thumb0452 = '$thumb1' thumb0234 = '$thumb2' thumb0678 = '$thumb3' thumb0876 = '$thumb4' thumb0123 = '$thumb5' I assume I would start with something like this: PHP Code:
View Replies !
Fatal Error: Cannot Re-assign $this
i am running a code created with php4 on a php5 engine and I am running into problems with the $this . In php4 its a variable and in php5 its a ref to a class object (if am right) I get the following error in a class "Fatal error: Cannot re-assign $this in {path}" which is caused by this line "$this = new $db( $serv, $user, $pass, $dbName );" How can i resolve this ? am thinking of renaming $this to something like $this_var but then this is likely not to work.
View Replies !
Assign Table Value As A Session??
someone logs into my application - a login function runs from a pinc file. What is suppose to happen is if the username and password match - it is suppose to assign a session to the username - which is being passed from form and to the first and last name which are in the table for the user. Can I assign a session variable to value in a mysql table? It does properly set the cookie I am assigning on the setCookie line but is is not setting any of the three sessions. Here is the function I am using: Code:
View Replies !
Assign Function To Class....
Is it possible to assign some functions to a of a class? class loginClass { function initialize() {$something} } function CheckLogin() { $something } $login = new loginClass(); $login->onLogin = CheckLogin(); $login->initialize(); where the CheckLogin function will only be run during the initialize of the class, not during loading of the whole document.
View Replies !
Assign Class Variables
I have a class with several variables, and I need to set them. I want to do them in a loop instead of assigning variables one at a time. How do I do that? Keep in mind that some animals don't have certain features, like wings, so those classes don't have wings as variables. The reason I need to do that is because I have many animals besides dog, and I am doing same thing over and over again in each different php file for each animal. I am trying to combining them into one php file. class dog { var ear; var tail; var eye; } dog = new dog; dog->ear = 1; dog->tail = 1; dog->eye = 2;
View Replies !
Drop Down To Assign Cookie ..
I am trying to create a drop down menu using PHP that will assign a value to a Cookie. I'm not sure how to script something to do this, but I am providing an example of the code i am trying to use. I would appreciate it if someone could show me the correct way to write a code that will assign the cookie "color" value. Code:
View Replies !
Assign Value From A Drop Down Menu
I am trying to assign a value to a PHP variable from a drop down menu. The default value is "no." However if "yes" is chosen, I want that to be assigned to $_POST['local_pickup'] Here is what I have so far: <select> <option class = "blue_standard">No</option> <option class = "blue_standard">Yes</option> <?php if ($_POST['local_pickup'] == 'yes') echo $_POST['local_pickup']; ?> </select> Can anyone suggest how to get the yes value assigned to the $_POST['local_pickup'] variable if "yes" is chosen.
View Replies !
Assign New Values To HTTP_POST_VARS
I have a form that post 9 variables to a page, in action page i want to assign "OPTIONAL" as value to all variables which are posted Blank, for example if Salary field is posted Blank then assign it word "Optional" and then use it to insert into database so that in database insteasd of blank it will contain "Optional". I have done the following coding. PHP Code: $spitter=$HTTP_POST_VARS; foreach($spitter as $op=>$val) { if ($val=="") $val="Optoinal"; } foreach ($HTTP_POST_VARS as $temp =>$sub) { $sub = $temp->$val; } the first part of the code is working, but when i again assign new values to HTTP_POST_VARS array its not working, and not taking the new values, i want assign new values from array SPITTER to HTTP_POST_VARS so that in further code i can use HTTP_POST_VARS to insert data into table.
View Replies !
Assign Source Code
I have a variable ($source) which i would like to assign the source code of another page to. I would like to do this so i can parse through it all and pull out a few key bits of info (current bid, number of bids, time remaining) from the autions i have listed.
View Replies !
How To Assign A Picture To A User
I am making a wannabe myspace for some friends to fart around with and was wondering if anyone could help me. I used a tutorial on uploading images but I need help assigning the uploaded image to the user that uploaded it.
View Replies !
Fatal Error: Cannot Re-assign....
I had to switch hosters again because the hoster I recently switched to has errors when using imap connections and they can't figure out what is wrong. Or that's what they are telling me. So, on my new hoster everything seems to be great except I'm getting a: Fatal error: Cannot re-assign $this in /home/**/public_html/MailCenter/text_funcs.php on line 84.
View Replies !
Fatal Error: Cannot Use Assign-op Operators
Getting the following error message: "Fatal error: Cannot use assign-op operators with overloaded objects nor string offsets" The PHP file includes one rather substantial array. I tried taking a few lines out of it just in case the sheer size of the array was giving me prolems, but this made no difference. PHP Code:
View Replies !
How Do We Assign 16 Bytes Unsigned Integer In PHP?
We are unable to represent an unsigned integer with 16 bytes memory size. The current integer size is 4 bytes by default. There is no way for us to store large integer in this case. The valid number range is from 0 to 2^128-1 (340282366920938463463374607431768211455).
View Replies !
Upload A File, Assign It A Random Name
I'm trying to upload a file, assign it a random name and then reference it too a database. I am using the following script to achieve this but its not working, when I run it all I get is my own error message "Sorry, there was a problem uploading your file.". It is however putting a random number into the databse but it is not adding the extinsion type back on. Code:
View Replies !
Assign Multiple Numeric Values
I have a form in one field of which users can choose one of several items. As an example let's say it is fruit they are choosing, apples, oranges, bananas, lemons etc. I later need to assign a numeric value to their choice, but rather than doing multiple ifs if($Fruit == "apples") { $FruitValue = 120; } elseif ($Fruit == "oranges") { $FruitValue = 80; } etc is there a way to do this in one go, without all the ifs?
View Replies !
How To Assign Which Table To LIMIT In From A JOIN?
I'm joining two tables "classrooms" and "students". 'Classrooms' has 7 school subjects and 'Students' has a list of students with their grades from the classrooms. I'm trying to do a while loop pulling a list of all the classrooms and pull only 1 student with the highest grade displayed next to the classroom. I did a JOIN but it's displaying all the students on each class. Code:
View Replies !
Assign Column Names As Array Keys
Want to create an array that has db column names for the key names and field values as the array values. Is there an easy way to do this? If not possible directly, is there a way in php/mysql to get a list of column names in a table such that I could use those values as the keys?
View Replies !
Assign Mysql Record Values To Gloabl Variabel
I've been struggle with the code below. I've tried mysql_fetch_assoc and various other functions, but can't seem to get it to work. The code works as far as that point though. global $first_name; global $last_name; global $password; function get_acct_rec($email){ $conn = db_connect(HOST, USER, PASS, DB, PORT); $sql = "SELECT * FROM `clients` WHERE `email` = '" . $email . "'"; $c_result = mysql_query($sql, $conn) or die("Failed to execute query at line " . __LINE__ . ": " . db_error($conn)); while ($row = mysql_fetch_assoc($c_result)) { $first_name = $row['first_name']; $last_name = $row['last_name']; $password = $row['password']; echo $row['first_name']; } mysql_free_result($result); db_close($conn); }
View Replies !
|