Jump to content

Search the Community

Showing results for tags 'variable'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 19 results

  1. Alright I am so close but can not figure this out, thanks in advance for any help. So what I am trying to do is take the input variables from a form and have them load a specific PDF . <html> <body> <?php if( $_GET["startpoint"] || $_GET["endpoint"]) { $a = $_GET["startpoint"]; $b = $_GET["endpoint"]; echo "Your Startpoint is:". $_GET["startpoint"]. "<br />"; echo "Your Endpoint is: ". $_GET["endpoint"]. "<br />"; echo $a,$b,".pdf"; } ?> </body> </html> This is what I have and it works to display what the two points are what the final pdf file should be. The final echo generates the PDF name echo $a,$b,".pdf"; How can I get it to load a file using this as a variable or the name it generates, thanks.
  2. Hey! I want to create a website that can test your counting pace. I’ll make colored, square div that change color after 10 to 30 seconds when you hover over it, and then you’ll type down how long you think it took in a form to check if you’re right. My solution to do this is to create the PHP variable $time = rand(10,30), and in CSS get the div:hover transition-delay to be $time. Then, after the form, I need the same variable for if($_POST[timeguess] = $time) {echo “Correct!”}. I have no idea how to access the same variable in both the CSS and HTML, so I hope some of you can help me out! Thanks
  3. I asked this question before and I did receive the answer I was looking for. But now I realize something. It only works for the first result. Let me explain. I am using this API. https://block.io/api/simple/php $get_address = $block_io->get_transactions(array('type' => 'received', 'addresses' => $my_wallet)); $api_amount = $get_address->data->txs[0]->amounts_received[0]->amount; $api_recp = $get_address->data->txs[0]->amounts_received[0]->recipient; $api_trans_id = $get_address->data->txs[0]->txid; $api_sender_id = $get_address->data->txs[0]->senders; These are variables above i am using to check if something is true or not. For eg. The form below. I want to check if the $api_trans_id matches the the post id I submit below. if($api_trans_id == $_POST['trans-id']) { echo 'Success'; } else { echo 'Fail.'; } <form action="" method="post"> <input type="text" name="trans-id" value="" maxlength="1084" /> <input type="submit" name="submit" value="Submit" /> </form> The above works if the first result in the json array below has the same post id or else it fails. I want to loop through ALL the json arrays and try to match the post id($_POST['trans-id']). Below are the 3 array results to give you an example. The first txid is "41d9afcc73da63c45674088411460116cfefe324cc7a6f5fcb267d9f584adf73". If I submit this same id as the post id in the form, it'll be success full. But if I use the 2nd or 3rd txid below, it will fail. So how can I change this "$api_trans_id = $get_address->data->txs[0]->txid;" so that it looks for all three txid instead of only the first one? { "status" : "success", "data" : { "network" : "BTC", "txs" : [ { "txid" : "41d9afcc73da63c45674088411460116cfefe324cc7a6f5fcb267d9f584adf73", "from_green_address" : false, "time" : 1496877627, "confirmations" : 3080, "amounts_received" : [ { "recipient" : "1QFaAYB4r8sk7MG3beb7yY4R21t9JrnMwK", "amount" : "0.00200000" } ], "senders" : [ "2EqvPUTwjUuon6c2a6YxBreJtBkkZD5fsp" ], "confidence" : 1.0, "propagated_by_nodes" : null }, { "txid" : "2f72d4dd97234937ddf6e8174b17a9a421ba35bbfb6fa40cfeb6ac92db6ce032", "from_green_address" : false, "time" : 1491675979, "confirmations" : 12338, "amounts_received" : [ { "recipient" : "1QFaAYB4r8sk7MG3beb7yY4R21t9JrnMwK", "amount" : "0.00010000" } ], "senders" : [ "3L98MQZKvwNo21fFpY7RJ9HYfYdv62XpYz" ], "confidence" : 1.0, "propagated_by_nodes" : null }, { "txid" : "fce58f0cb1d32c1ed7c27825c41753ce98323771bd931f0a0f99b6294d9ee642", "from_green_address" : false, "time" : 1491672301, "confirmations" : 12341, "amounts_received" : [ { "recipient" : "1QFaAYB4r8sk7MG3beb7yY4R21t9JrnMwK", "amount" : "0.00010000" } ], "senders" : [ "4L98MQZKvwNo21fFpY7RJ9HYfYdv62XpYz" ], "confidence" : 1.0, "propagated_by_nodes" : null }, ] } }
  4. Hello so I have a simple code here that will check if a random number already exists in the database and will generate a new one: $rand = mt_rand(100000, 999999); $sid = array( ":sponsorID" => $rand ); $accounts = $db->select("accounts", "sponsorID = :sponsorID", $sid) while(count($accounts) > 0) { $newNum = mt_rand(100000, 999999); } What I wanted to do is to echo out $newNum. When I echo it out I get undefined index of that variable. How can I solve this?
  5. undefined variable errorString. what's wrong with this? Notice: Undefined variable: errorString in /Applications/XAMPP/xamppfiles/htdocs/finalproject/donate/thankyou.php on line 97 Notice: Undefined variable: messageString in /Applications/XAMPP/xamppfiles/htdocs/finalproject/donate/thankyou.php on line101 <?php require "config.php"; require "connect.php"; if(isset($_POST['submitform']) && isset($_POST['txn_id'])) { $_POST['nameField'] = esc($_POST['nameField']); $_POST['websiteField'] = esc($_POST['websiteField']); $_POST['messageField'] = esc($_POST['messageField']); $error = array(); if(mb_strlen($_POST['nameField'],"utf-8")<2) { $error[] = 'Please fill in a valid name.'; } if(mb_strlen($_POST['messageField'],"utf-8")<2) { $error[] = 'Please fill in a longer message.'; } if(!validateURL($_POST['websiteField'])) { $error[] = 'The URL you entered is invalid.'; } $errorString = ''; if(count($error)) { $errorString = join('<br />',$error); } else { mysql_query(" INSERT INTO dc_comments (transaction_id, name, url, message) VALUES ( '".esc($_POST['txn_id'])."', '".$_POST['nameField']."', '".$_POST['websiteField']."', '".$_POST['messageField']."' )"); if(mysql_affected_rows($link)==1) { $messageString = '<a href="donate.php">You were added to our donor list! »</a>'; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Thank you!</title> <link rel="stylesheet" type="text/css" href="styles.css" /> </head> <body class="thankyouPage"> <div id="main"> <h1>Thank you!</h1> <h2>Add Yourself to our Donor Section</h2> <div class="lightSection"> <form action="" method="post"> <div class="field"> <label for="nameField">Name</label> <input type="text" id="nameField" name="nameField" /> </div> <div class="field"> <label for="websiteField">Web Site</label> <input type="text" id="websiteField" name="websiteField" /> </div> <div class="field"> <label for="messageField">Message</label> <textarea name="messageField" id="messageField"></textarea> </div> <div class="button"> <input type="submit" value="Submit" /> <input type="hidden" name="submitform" value="1" /> <input type="hidden" name="txn_id" value="<?php echo $_POST['txn_id']?>" /> </div> </form> <?php if($errorString) { echo '<p class="error">'.$errorString.'</p>'; } else if($messageString) { echo '<p class="success">'.$messageString.'</p>'; } ?> </div> </body> </html> <?php function esc($str) { global $link; if(ini_get('magic_quotes_gpc')) $str = stripslashes($str); return mysql_real_escape_string(htmlspecialchars(strip_tags($str)),$link); } function validateURL($str) { return preg_match('/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/i',$str); } ?>
  6. Folks, Q1. A function parameter that takes in a constant, can it always take in a variable, unless it needs a handle ? While going through the Explode function tutorial, I did not come across anything that states the 3rd parameter (explode limit) in the Explode function has to be a string or a constant. Like so: <?php //Tutorial: http://www.tizag.com/phpT/php-string-explode.php echo "Script 1"; //Using a Constant as 3rd parameter in the Explode function. Using FOR function. $phrase = "Please don't blow me to pieces."; $words = explode(" ", $phrase); print_r($words); for($i = 0; $i < count($words); $i++){ echo "Piece $i = $words[$i] <br />"; } $explode_limit = 4; $words = explode(" ", $phrase, 4); for($i = 0; $i < count($words); $i++){ echo "Limited Piece $i = $words[$i] <br />"; } print_r ($words); ?>
  7. How can i Add Screen Resolution to PHP Variable and Echo it? i am quite confused on how to do this as getting resolution is done in javascript right? Please help me with this. i have coded my first wordpress theme and this is the only part i am stuck at p.s. I want to save screen height in different variable and screen width in different variable.
  8. Below I have "Input" where it shows the original string. Basically I want to remove everything before " - ". I would like to know how can I get the "Output" results using PHP? Input $variable_1 = Lulu-free - Swimsuit swimwear red $variable_2 = Pap & Jones - Bard Mini Dress Output $variable_1 = Swimsuit swimwear red $Variable_2 = Bard Mini Dress
  9. Hi All, couldn't seem to figure how to pass data from page 2 to page 1. On page 2 I have this code block: # if the form has been posted if ($_SERVER["REQUEST_METHOD"] == "POST") { # check for empty fields if (!empty(trim(($_POST['name'] == '')))) { $nameErr = "<span class=\"error\">Name is required</span>"; } if (!empty(trim(($_POST['email'] == '')))) { $emailErr = "<span class=\"error\">Email is required</span>"; } # if all is fine, then add data to the database else { $sql = 'INSERT INTO author SET name = :name, email = :email'; $query = $dbConnection -> prepare($sql); $query -> bindValue(':name', $_POST["name"]); $query -> bindValue(':email', $_POST["email"]); $query -> execute(); $message = 'done'; header('Location: index.php'); } } The variable $message I wanted to pass to page 1, where I have this in: <?php if(isset($_POST['message'])) { echo $_POST['message']; } ?> I can't seem to figure out the problem? Any tips? Thanks
  10. Say I have the following. record_id | record_name ----------------------------------- 1 one 2 two 3 three 3 three 3 three 4 four 5 five 5 five I want to search through through the table and find all the records. If there are multiple records with same id, I want to combine them into 1 variable and use that. So in the above example, I have 3 threes and 2 fives. I want to combine them so that I only get 1 three and 1 five. How can that be done? A normal query looks like this. $get_records = $db->prepare("SELECT * FROM records"); $get_records->execute(); $result_records = $get_records->fetchAll(PDO::FETCH_ASSOC); if(count($result_records) > 0) { foreach($result_records as $row) { $record_id = $row['record_id']; $record_name = $row['record_name']; } }
  11. Say I have this array. $block_io->get_current_price(array()); That array will give me this output. { "status" : "success", "data" : { "network" : "BTC", "prices" : [ { "price" : "1500.01", "price_base" : "AUD", "exchange" : "coinspot", "time" : 1488955012 }, { How can I convert the above output into individual variables? For eg. $status = 'success'; $network = 'BTC'; $price = '1500.01'; ...etc
  12. Hi all, I want to echo two variables inside the body of automatic email. i am trying to get those two variables from the form that customer just submitted. i am posting my code below, please help ASAP. Thanks in advance <?php if(isset($_POST['button_pressed'])) { $to=$Email; $subject='Hi There!!'; $body='Hi'; $Title . '' . $Surname; ', This is a demo email sent using PHP on XAMPP'; if (mail($to,$subject,$body)){ echo 'Mail sent successfully!'; } else{ echo 'Mail not sent!'; }} ?>
  13. Hi, I want to set a variable based on the contents of another variable - I think I've see CASE used for this before but not entirely sure. Basically I'm trying to tidy this up: if ($var1 = "1") { $var2 = "a" } if ($var1 = "2" ) { $var2 = "b" } if ($var1 = "3") { $var2 = "c" } Any help appreciated. Thanks.
  14. I have a simple web page with 2 buttons that change an icon to red or green based on which button is pressed. When the button is pressed, the variable is stored in a text file, and then recalled to display the proper color icon. (When "Power On" is pressed, the icon turns red, and when "Power Off" is pressed, it turns green.) The problem I have is this: When the page is first loaded, the graphic is blank, until a button is pressed, and then the icon displays properly. The text file with the stored variable is always available on the server, but I cant figure out why the page isnt working properly. I know my webpage is probably full of other problems, but I am a real noob, trying to create my home automation webpage... If you are wondering why I am storing the variable in a text file, it was my way of saving this variable, so that another user could open the same webpage at another time, on another computer, and be able to see the correct status icon. if there is a better way (without Java), please let me know! Here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php ///////////////////////////////////////////////////////////////////////////////////////////// // Check of LED2 is set. If it is, then use it if (isset($_POST["LED2"])) { $LED2= $_POST["LED2"]; //echo "<b>$LED2</b>"; } else { $LED2 =""; } if ($LED2 == "ON") { // Set led2 ON by calling the Arduino using fopen $h = @fopen("http://192.168.5.21/?LED=T", "rb"); $image = "/Graphics/LED_red.bmp"; } else if ($LED2 == "OFF") { // Set led2 OFF by calling the Arduino using fopen $h= @fopen("http://192.168.5.21/?LED=F", "rb"); $image = "/Graphics/LED_green.bmp"; } ///////////////////////////////////////////////////////////////////////////////////////////// // set and write data to text file { $fp = fopen('graphic.txt','w'); fwrite($fp,$image); } ///////////////////////////////////////////////////////////////////////////////////////////// // Reading the data from text file $graphictemp = file_get_contents('graphic.txt'); $graphic = ($graphictemp); ?> <head> <style type="text/css"> body { font: 100% Verdana, Arial, Helvetica, sans-serif; background: #666666; margin: 0; padding: 0; text-align: center; color: #000000; } .newStyle1 { float: left; } .auto-style1 { color: #FFFFFF; font-size: 20px; } </style> <title>Audio Control</title> </head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <body> <form action="" method="post" > <fieldset style="display:inline; border:none; padding:0px; margin:0px; vertical-align:top; class="newStyle1" style="height: 450px" > <legend align="center" class="auto-style1">Amplifier <img name="LED" src="<?=$graphic?>" width="12" height="12" alt="" style="background-color: #FFFFFF" /></legend> <br/> <button name="LED2" style="height: 1.8em; width: 10em; font-size: 16px;" value="ON" type="submit">Power On</button> <br /> <br /> <button name="LED2" style="height: 1.8em; width: 10em; font-size: 16px;" value="OFF" type="submit">Power Off</button> <br /> <br /> </fieldset> </form> </body> </html>
  15. I have a mysql field that I want to store a php variable in and then retrieve it. Example: Color table has the field named colorBackground with the value of #FF0000 CSS table has the field named cssBackground with the value of .background { background-color: #444444; } What I want to do is make Color/colorBackground a variable {{$backgroundcolor = rsColor['colorBackground'] Then I want to change the CSS/cssBackground value to .background { background-color:$backgroundcolor; } Creating the $backgroundcolor works fine. I'm just not sure how to put the $backgroundcolor in my CSS/cssBackground field.
  16. I have a register form where a user enters a full name, email and password. I do not want to give them the option of choosing their own "username"; rather I want to automatically create the username from their "full name". So far I can create the username by removing space and symbols from full name. Like this. $fullname = trim($_GET['fullname']); $username = preg_replace('/\s+/', '', $fullname); Looking at that, John Smith would become "johnsmith". Since there could be dozens of people with the name "john smith", I was thinking of assigning unique number to each of them. Like this "johnsmith1", "johnsmith2", "johnsmith3"..etc. How would you say I go on incrementing the username like that?
  17. Php Gurus, I have been doing guess work all this time. But not any more. Just gonna ask. Look at the following code: Concentrate on line 5. It is obvious the "$colors" represent the variable name of the whole array thing (or "column" or "row" in MS Excell terminology). But what does the "$value" represent ? Each array's values (or "cell" value in MS Excell terminology) ? So, the value of the variable $value changes on each loop. Right ? From "Red" to "Orange" at the end. Correct ? Example: 1st loop: $value = Red; 2nd loop: $value = Green; And so on. Correct ? <?php $colors = array("Red", "Green", "Blue", "Yellow", "Orange"); // Loop through colors array foreach($colors as $value){ echo $value . "<br>"; } ?>
  18. I have the following three links in same page. http://localhost/folder/file.php?x=link1 http://localhost/folder/file.php?x=link2 http://localhost/folder/file.php?x=link3 i want to show URLs as they are... link1 is to include a file named "x.php" link2 is to include a file named "y.php" link3 is to include a file named "z.php" Can it be done in php only? PS: its not about creating hash ids. and i want to do it without any sql db connection.
  19. I've got a function in my WordPress functions file that sends a Word doc based on what venue the ordered product is from. However I also need to be able to paste variables such as the customer name and others onto the specified word document. It also needs to be in specific places. How can I go about doing this? Please let me know if you have any idea or don't understand me! Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.