Search Results

Search found 42698 results on 1708 pages for 'php in array'.

Page 145/1708 | < Previous Page | 141 142 143 144 145 146 147 148 149 150 151 152  | Next Page >

  • 3 small PHP errors I cannot decipher

    - by Dave
    *Notice: Use of undefined constant _ - assumed '_' in /.../uploader.php on line 45* Line 45 $newname = str_replace(array(' ', '&'), array('_', 'and'), trim( strip_tags( $_POST['name'] ) ) ) . _ . $formKey->generateKey() . '_' . time() . '.jpg'; Notice: Undefined index: approve in /.../uploader.php on line 81 Line 81 - the second last line here $query = sprintf("INSERT INTO `$db_name`.`the_table` (`id` , `name` , `photo` , `email` , `date` , `code` , `subscribe` , `approve` , `created` ) VALUES ( NULL , '%s', '%s', '%s', '%s', '%s', '%s', '1', CURRENT_TIMESTAMP );", mysql_real_escape_string($_POST['name']), mysql_real_escape_string($newname), mysql_real_escape_string($_POST['email']), mysql_real_escape_string($date), mysql_real_escape_string($_POST['code']), mysql_real_escape_string($subscribe), mysql_real_escape_string($_POST['approve']) ); Warning: Cannot modify header information - headers already sent by (output started at /.../uploader.php:45) in/.../uploader.php on line 102 Line 45 $newname = str_replace(array(' ', '&'), array('_', 'and'), trim( strip_tags( $_POST['name'] ) ) ) . _ . $formKey->generateKey() . '_' . time() . '.jpg'; Line 102 - the third line here if ($success == 'Done') { $page = 'uploader'; header('Location: ./thanks.php'); } else { echo "error"; }

    Read the article

  • PHP Dropdown menu [closed]

    - by rShetty
    <br><h2>Select a Tag</h2></br> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("portal", $con); $query = "SELECT tag_name FROM tags"; $result = mysql_query($query); ?> <select name="tag_name" id="abc"> <option size=30 selected>Select</option> <?php while($array = mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $array['tag_name'];?>"><?php echo $array['tag_name'];?> </option> <?php } ?> </select> <br><br> This is a snippet of code for getting the dropdown menu in the page. I have a database named portal and table named tags with tag_name as the attribute. Do help me to find the error in the program. I am not getting the tag_names in the dropdown menu

    Read the article

  • got undefined variable in php code

    - by Newbie New
    I got a error message when I run my php however the result is come out this is my code function cart() { foreach($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0, 5) == 'cart_'){ $id = substr($name, 5, (strlen($name)-5)); $get = mysql_query('SELECT id, name, price FROM products WHERE id=' .mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)){ $sub = $get_row['price'] * $value; echo $get_row['name'].' x '.$value.' @ &pound'.number_format($get_row['price'], 2).' = &pound'.number_format($sub, 2).' <a href="cart.php?remove='.$id.'">[-]</a> <a href="cart.php?add='.$id.'">[+]</a> <a href="cart.php?delete='.$id.'">[Delete]</a><br />' ; } } $total += $sub; } } echo $total; } ?> I got a error message Notice: Undefined variable: total in C:\xampp\htdocs\shoppingcart\cart.php on line 54 which line 54 is echo $total; what's wrong with my code?? I think I have defined the code in $total += $sub; thanks for helping me :)

    Read the article

  • Access PHP var from external javascript file

    - by FFish
    I can access a PHP var with Javascript like this: <?php $fruit = "apple"; $color = "red"; ?> <script type="text/javascript"> alert("fruit: " + "<?php echo $fruit; ?>"); // or shortcut "<?= $fruit ?>" </script> But what if I want to use an external JS file: <script type="text/javascript" src="externaljs.js"></script> externaljs.js: alert("color: " + "<?php echo $color; ?>");

    Read the article

  • What is PHP like as a programming language?

    - by seanlinmt
    I am not really familiar with PHP, but I get the impression that it is like JavaScript (syntax-wise). What are the benefits of a dynamically typed language, when compared to a strongly typed language like C# or Java, and how would this help in the context of web development? What would make a dynamically typed language so attractive? Or, does the popularity of PHP have more to do with it being free? Okay, I think I better give a little more background to get more meaningful answers, because I am not wanting a flame war. I come from a C background, and when I moved into C# and Visual Studio. Having code completion, integration with an SQL database, huge existing class libraries and easy to access documentation, as well as new tools such as LINQ and ReSharper was like heaven. I didn't enjoy JavaScript before JQuery, but now I love it as well. Recently, I ported a PHP project over to C# and I used Zend to help me debug and understand more while porting - instead of maintaining two code streams. That also cut down on the cost of the server and maintenance. Getting into PHP would be nice. I think that Visual Studio has spoiled me - but again Eclipse is also equally spoiling. It would be nice to have an answer from someone who has experience developing both under PHP and .NET.

    Read the article

  • How to use the php fopen() correctly

    - by Jacksta
    I am learning php, trying to use the fopen() function. The php file I am coding is in this directory /domains/xxxxx.com.au/public_html/phpfile.php What path do I specify for the file to be opened, the example I am looking at is based on a server on a pc where this is the file path $filename = "c:/newfile.txt"; not an online server.

    Read the article

  • PHP Echo current filename without extension

    - by Christian Nikkanen
    I'm working on a very simple homemade CMS that simply uses a rich text editor and database to save the website contents and displays them to visitors. Heres the save.php that saves it: <?php include 'mysqlconnection.php'; mysql_query("UPDATE Content SET Content='$_POST[edit]' WHERE PageName='$_POST[PageName]'"); mysql_close($con); ?> <?php header('Location:http://xxx.com/Kayttoliittyma'); ?> It just saves it to the database. The pagename part is the part where I need to echo the filename without the extension. It would echo to the forms hidden field. But how?

    Read the article

  • Visual PHP GUI IDE

    - by Joshua
    Does anybody know of a reliable, well-made tool for creating standalone desktop applications complete with GUI, using just PHP, or primarily PHP? I enjoy the R.A.D. and many other aspects of PHP and would like to use it for some non server/client projects.

    Read the article

  • Passing array of pointers to another class

    - by user310153
    Hi, I am trying to do the following: in main.cpp: // Create an array of pointers to Block objects Block *blk[64]; for (i=0; i<8; i++) { for (j=0; j<8; j++) { int x_low = i*80; int y_low = j*45; blk[j*8+i] = new Block(30, x_low+40.0f, y_low+7.5f, &b); } } And then I am trying to pass it to the graphics object I have created: Graphics g(640, 480, &b, &p, blk[0], number_of_blocks); the graphics constructor looks like: Graphics::Graphics(int width, int height, Ball *b, Paddle *p, Block *blk, int number_of_blocks) { if I look at what is contained in the array from the graphics object, only the first item exists and then all the other items are in hyperspace: for (int i=0; i<64; i++) { printf("for block %d, %f, %f ", i, (_blk+(sizeof(_blk)*i))->_x_low, (_blk+(sizeof(_blk)*i))->_y_low); printf("blah %d\n", (_blk+(sizeof(_blk)*i))); } and if I look at the addresses, they are different (6956552 rather than 2280520 when I examine the addresses in the main class using: printf(" blah %d\n", &blk[j*8*i]); I am sure there must be something subtle I am doing wrong as its like I have copied the first item from the blk array to a new address when passed to the graphics object. Does this make sense? Any ideas? Cheers, Scott

    Read the article

  • What is wrong with this php loop?

    - by Mark R
    I made a loop but it doesn't work. here's what I did: <?php if(is_tree('4')) { ?> <?php $show_after_p = 2; $content = apply_filters('the_content', $post->post_content); if(substr_count($content, '<p>') > $show_after_p) { $contents = explode("</p>", $content); $p_count = 1; foreach($contents as $content) { echo $content; if($p_count == $show_after_p) { ?> YOUR AD CODE GOES HERE < ? } echo "</p>"; $p_count++; } } ?> <?php else : ?> <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?> <?php endif; } ?> I need to make it work but don't know how. I'm guessing it's a simple syntax error I'm not seeing?

    Read the article

  • How to manually create Friendly URLs? (PHP)

    - by Ole Jak
    How to manually create Friendly URLs? (PHP) So I have created simple php file which echos requested string. Now it has form echo.php?string=bla+bla+bla&font=times I want to see it like echo/bla+bla+bla/times How to do such thing (not using external libs)?

    Read the article

  • how to execute a .exe program by php script

    - by user347262
    hello I want to execute a .exe file on my Apache server using a php script. the procedure is as follow: 1- user comes, fills a html form 2- it goses to a php script 3- php script executes the name.exe file 4- php prints the output of the name.exe file on the page. I execute the name.exe normally from windows like this: run--> cmd--> D:\name [command] the name.exe needs to communicate with other files like libraries in the same directory. the complete comand in cmd at windows is like this: D:\name library.dll [input from user] then program executes and prints some results in cmd window. I actually want to run this program on my server form my clients. I dont know how, but I now there is a way to do this. another related questoin is that, is there any shell that i can install on Linux server and execute name.exe in it? thanks in advanced, John.

    Read the article

  • Fake Template Engine php

    - by user1464822
    i got an idea for making php template engine fast and user friendly but i'm not sure if it's good or bad. the idea is to create a fake template engine: creating a template editor in control panel that let user see something like this: <html> <head> <title>{title}</title> </head> <body> {content} </body> </html> what the editor actually does is to replace all php code like <?php echo $this->title; ?> to user friendly {title} but it's not really replacing it just in the view when the user save the template the template actually saved as fast pure php template. the question is this a good idea or bad ? your answers is highly appreciated.

    Read the article

  • memcache, wamp, php 5.4, win8

    - by user1406269
    I am using wamp, PHP 5.4 running on win 8, I can't seem to get PHP to acknowledge the memcache dll. I download php_memcache-3.0.8-5.4-ts-vc9-x86.zip (the only one I could find). I copied the dll to C:\wamp\bin\php\php5.4.12\ext I added extension=php_memcache.dll restart the server. but still I cannot use memcache, and it is missing from Loaded Extensions list. Please supply a step-by-step instruction on how to set this up, Thanks.

    Read the article

  • Easiest way to submit data via PHP?

    - by Abijah
    I'm new to PHP, and have spent 10 hours trying to figure this problem out. The goal is to take all data entered into this order form, and send it to my email via PHP. I have 2 questions: 1. I can get PHP to send data from a single menu item (example: Mexican Tortas), but how do I get PHP to send data from multiple items (example: Mexican Tortas, Fish Sandwich and Hamburger)? 2. How do I tell PHP to not send data from menu items that don't have the "How Many?" or "Customize It?" text fields filled out? If you could provide a super simple example (or a link to a learning resource) I would really appreciate it. Thank you, Abijah PHP <?php if(isset($_POST['submit'])) { $to = "[email protected]"; $subject = "New Order"; $name_field = $_POST['name']; $phone_field = $_POST['phone']; $item = $_POST['item']; $quantity = $_POST['quantity']; $customize = $_POST['customize']; } $body = "Name: $name_field\nPhone: $phone_field\n\nItem: $item\nQuantity: $quantity\nCustomize: $customize"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); ?> HTML <form action="neworder.php" method="POST"> <div class ="item"> <img style="float:left; margin-right:15px; border:1px Solid #000; width:200px; height:155px;" src="images/mexicantortas.jpg"> <h1>Mexican Torta - $8.50</h1> <input name="item" type="hidden" value="Mexican Torta"/> <h2>How Many? <font color="#999999">Ex: 1, 2, 3...?</font></h2> <input name="quantity" type="text"/> <h3>Customize It? <font color="#999999">Ex: No Lettuce, Extra Cheese...</font></h3> <textarea name="customize"/></textarea> </div><!-- ITEM_LEFT --> <div class ="item"> <img style="float:left; margin-right:15px; border:1px Solid #000; width:200px; height:155px;" src="images/fishsandwich.jpg"> <h1>Fish Sandwich - $8.50</h1> <input name="item" type="hidden" value="Fish Sandwich"/> <h2>How Many? <font color="#999999">Ex: 1, 2, 3...?</font></h2> <input name="quantity" type="text"/> <h3>Customize It? <font color="#999999">Ex: No Lettuce, Extra Cheese...</font></h3> <textarea name="customize"/></textarea> </div><!-- ITEM_LEFT --> <div class ="item"> <img style="float:left; margin-right:15px; border:1px Solid #000; width:200px; height:155px;" src="images/hamburgers.jpg"> <h1>Hamburger w/ Fries - $7.00</h1> <input name="item" type="hidden" value="Fish Sandwich"/> <h2>How Many? <font color="#999999">Ex: 1, 2, 3...?</font></h2> <input name="quantity" type="text"/> <h3>Customize It? <font color="#999999">Ex: No Lettuce, Extra Cheese...</font></h3> <textarea name="customize"/></textarea> </div><!-- ITEM_LEFT --> <div class="horizontal_form"> <div class="form"> <h2>Place Your Order Now: <font size="3"><font color="#037B41">Fill in the form below, and we'll call you when your food is ready to be picked up...</font></font></h2> <p class="name"> <input type="text" name="name" id="name" style="text-align:center;" onClick="this.value='';" value="Enter your name"/> </p> <p class="phone"> <input type="text" name="phone" id="phone" style="text-align:center;" onClick="this.value='';" value="Enter your phone #"/> </p> <p class="submit"> <input type="submit" value="Place Order" name="submit"/> </p> </div><!-- FORM --> </div><!-- HORIZONTAL_FORM --> </form>

    Read the article

  • Problems Expanding an Array in C++

    - by dxq
    I'm writing a simulation for class, and part of it involves the reproduction of organisms. My organisms are kept in an array, and I need to increase the size of the array when they reproduce. Because I have multiple classes for multiple organisms, I used a template: template <class orgType> void expandarray(orgType* oldarray, int& numitems, int reproductioncount) { orgType *newarray = new orgType[numitems+reproductioncount]; for (int i=0; i<numitems; i++) { newarray[i] = oldarray[i]; } numitems += reproductioncount; delete[] oldarray; oldarray = newarray; newarray = NULL; } However, this template seems to be somehow corrupting my data. I can run the program fine without reproduction (commenting out the calls to expandarray), but calling this function causes my program to crash. The program does not crash DURING the expandarray function, but crashes on access violation later on. I've written functions to expand an array hundreds of times, and I have no idea what I screwed up this time. Is there something blatantly wrong in my function? Does it look right to you? EDIT: Thanks for everyone's help. I can't believe I missed something so obvious. In response to using std::vector: we haven't discussed it in class yet, and as silly as it seems, I need to write code using the methods we've been taught.

    Read the article

  • PHP Error Form - Leave Contents of Form on Redirect

    - by user1371500
    I have a simple login form in which if an error occurs such as wrong password, I need it to be able to remember the username which was entered. Would I Go about doing this PHP or Javascript as I am not allowed to use JQuery. My current PHP - (Not Including the HTML Form) <?php //MySQl Connection mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("clubresults") or die(mysql_error()); //Initiates New Session - Cookie session_start(); // Start a new session // Get the data passed from the form $username = $_POST['username']; $password = md5($_POST['pass']); // Do some basic sanitizing $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); //Performs SQL Query to retrieve Login Details from DB $sql = "select * from admin_passwords where username = '$username' and password = '$password'"; $result = mysql_query($sql) or die ( mysql_error() ); //Assigns a Variable Count to 0 $count = 0; //Exectues a loop to increment on Successful Login while ($line = mysql_fetch_assoc($result)) { $count++; } //If count is equal to 1 Redirect user to the Members Page and Set Cookie if ($count == 1) { $_SESSION['loggedIn'] = "true"; header("Location: members.php"); // This is wherever you want to redirect the user to } else { //Else Echo that login was a failure. die('Login Failed. <a href=login.php>Click Here to Try Again</a>'); } ?> Any help would be appreciated. Cheers

    Read the article

  • Declaring static arrays in php

    - by user220201
    Hi, I am new to php. I was wondering how I could declare a static array in php. Here is what I would do in C. How is the corresponding php code for it? char a[][] = { (1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3) }; From what I read it has to be something like this - $a = array( 1 = array(1,1), 2 = array(1,2), ... ); Is this correct? If so it sucks :) I hope I am wrong. Thanks, - Pav

    Read the article

  • open url through header in php

    - by sumit
    I have a .php file in which i have a added a simple code: <?php header("Location:http//www.google.com"); ?> when i run this code, then instead of opening google.com it opens a download file, which is the same as my php file.

    Read the article

  • PHP: cannot matching string "<br />

    - by Patrick
    hi, I'm having problems with string matching in PHP. I've 2 html elements in my page, I've copy pasted here the content with Firebug <div class="field-item odd"> <div class="field-label-inline-first"> Year:</div> 2009 </div> <div class="field-item odd"> <div class="field-label-inline-first"> Synopsis:</div> &lt;br /&gt; </div> This php line works perfectly (the element with 2009 is detected) <?php if ($items[0]['view'] == '2009') : echo "ok"; ?> However I'm not able to match the string containing element: <?php if ($items[0]['view'] == '<br />') : echo "ok"; ?> //doesn't work <?php if ($items[0]['view'] == '&lt;br /&gt;') : echo "ok"; ?> //again doesn't work any tip ? To give you some context: The strings are produced by CKEditor, an editor I'm using in my Drupal back-end. When I leave empty this editor, the tag is displayed on the string as plain text (because I set "plain text" as formatting option in the back-end) Thanks

    Read the article

  • Object Oriented PHP books

    - by user275074
    Hi, I've realised just how rusty my knowledge of PHP 5 and advanced PHP programming is after completing some questions for a test. I seriously need to read a book or something. Any recommendations for PHP 5 books?

    Read the article

  • PHP shell_exec() - Run directly, or perform a cron (bash/php) and include MySQL layer?

    - by Jimbo
    Sorry if the title is vague - I wasn't quite sure how to word it! What I'm Doing I'm running a Linux command to output data into a variable, parse the data, and output it as an array. Array values will be displayed on a page using PHP, and this PHP page output is requested via AJAX every 10 seconds so, in effect, the data will be retrieved and displayed/updated every 10 seconds. There could be as many as 10,000 characters being parsed on every request, although this is usually much lower. Alternative Idea I want to know if there is a better* alternative method of retrieving this data every 10 seconds, as multiple users (<10) will be having this command executed automatically for them. A cronjob running on the server could execute either bash or php (which is faster?) to grab the data and store it in a MySQL database. Then, any AJAX calls to the PHP output would return values in the MySQL database rather than making a direct call to execute server code every 10 seconds. Why? I know there are security concerns with running execs directly from PHP, and (I hope this isn't micro-optimisation) I'm worried about CPU usage on the server. The server is running a sempron processor. Yes, they do still exist. Having this only execute when the user is on the page (idea #1) means that the server isn't running code that doesn't need to be run. However, is this slow and insecure? Just in case the type of linux command may be of assistance in determining it's efficiency: shell_exec("transmission-remote $host:$port --auth $username:$password -l"); I'm hoping that there are differences in efficiency and level of security with the two methods I have outlined above, and that this isn't just micro-micro-optimisation. If there are alternative methods that are better*, I'd love to learn about these! :)

    Read the article

  • Pass PHP variables without being seen when working with a database generated list

    - by Wilcoholic
    Looking for any help regarding the problem. Here's the deal: I have a database that has a teams table and it contains team_id. On one of my pages, I generate a list of links that contain the team_id of the creator in their get URL. I need the team_id on the next page but can't figure out how to pass it through any other way. Using a form and POST isn't an option because this method would only pass through the last links data on the list. Storing in a session isn't an option either because there is no way to discretely pass the the variables I need to a function to set the session variables. I have tried and it can pretty easily be viewed from viewing the source code. So here's some sample code to see exactly what I'm dealing with. <? if(mysql_num_rows($result2)>0){ ?> <a class="fltrt btn btn-danger btn-small" onclick="test()" href="acceptmatch-exec.php?match_id=<?php echo $match_id; ?>&team_id=<?php echo $team_id;?>&action=cancel">Cancel Match</a> <?}else{?> <a class="fltrt btn btn-success btn-small" href="acceptmatch-exec.php?match_id=<?php echo $match_id; ?>&team_id=<?php echo $team_id;?>&action=accept">Accept Match</a> <?} ?> The code above is generated multiple times on a page via a while loop that was excluded. I want to pass the match_id and team_id variables without being seen anywhere. If I made this a form, it wouldn't pass the correct variables unless there is only one result at the time (not likely). I'm sure there has to be an easy method that is eluding me, so please share thoughts on how to solve this. I feel as though I am not explaining it well enough, but it's not really easy to explain. I basically want something that works like GET but acts like POST and can be hidden from people viewing source code or link locations. Thanks

    Read the article

  • PHP display progress messages on the fly

    - by XaviEsteve
    Hi everyone, I am working in a tool in PHP that processes a lot of data and takes a while to finish. I would like to keep the user updated with what is going on and the current task processed. What is in your opinion the best way to do it? I've got some ideas but can't decide for the most effective one: The old way: execute a small part of the script and display a page to the user with a Meta Redirect or a JavaScript timer to send a request to continue the script (like /script.php?step=2). Sending AJAX requests constantly to read a server file that PHP keeps updating through fwrite(). Same as above but PHP updates a field in the database instead of saving a file. Does any of those sound good? Any ideas? Thanks!

    Read the article

< Previous Page | 141 142 143 144 145 146 147 148 149 150 151 152  | Next Page >