- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 8
- Posts with Upvotes
- 7
- Upvoting Members
- 7
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
54 Posted Topics
i have made a program in school that chooses a random number and you need to guess it. you put in a number and it says higher or lower. the only problem is that i can't set RAND_MAX and its a 4 or 5 diget number (havent figured it out … | |
Hi, I am running an Acer Aspire 5720 with Windows Vista Home Premium (32 bit) and I'm having trouble with the backlight killing button. fn + F6 is supposed to turn off the backlight until you show some activity but this function only seems to work only once per startup. … | |
Re: If you want to update the page without reloading it you will have to use [i]client side[/i] scripts such as Javascript. (PHP is a [i]server side[/i] language and so all the php is executed [i]before[/i] the page is sent to the clients browser. You will have to do some research … | |
Re: It seems there is an error in the tutorial you are using. the "@" symbol is actually used to suppress an error that the following function might throw: [url]http://www.tuxradar.com/practicalphp/19/8/12[/url] I'm assuming the author ment that to be a "$" symbol, as that indicates a variable. that line should be [icode][b]$[/b]AcmeInventory … | |
Re: I'm not that familiar with streaming video but I'm quite sure that if you want the browser to show something, you must tell it where it is. The browser then determines what to do with it, so it can show that code to the user if they want. All you … | |
Re: The easiest way to do this would be to set a column "lastactivity" to the current time every time the user loads any of your pages (just build it into your authentication script). You can then classify someone as "online" if they have been active in the past 5 mins. … | |
Re: Holy Moley, you'll hate your self for this :P You forgot a crucial line: [icode]mysql_query($sql);[/icode] which should go on line 16. As your code stands, it doesn't execute the new SQL command, just sets the $sql variable. Regarding the VALUE syntax, VALUE and VALUES are interchangeable. | |
Re: The problem you are having is with your double quotes. [code=php] echo "value of the constant CONSTANT: " . CONSTANT; [/code] notice the text in blue, this is a string. You are trying to put double quotes inside a string without escaping them. If you place a backslash directly before … | |
Re: You can use a for loop to operate on each element of the array. I'm assuming it's a one (meaningful) columned table. [CODE=c++] //len is length of array for (i=0; 0<len; i++){ //create SQL statement sql="INSERT INTO table (row1) VALUES " . array[i]; //[execute sql here] } [/CODE] Alternatively, you … | |
Re: Your form should look like this: [code=html] <form ...> <input type="hidden" name="student" value="$row['student']" /> <input type="submit" name="delete" value="Delete" /> </form> [/code] Then you can get which student to delete on deletestudent.php via $_POST['student']. (you can use [icode]isset($_POST['delete'])[/icode] to see if they clicked "Delete" but $_POST['delete'] will hold the value "Delete"). … | |
Re: Assuming you have all the data stored in a MySQL table you sould need something like this: [code=php] <?php //login to MySQL db $result=mysql_query("SELECT * FROM user_settings WHERE id='$_SESSION[user_id]'"); $settings=mysql_fetch_array($result); //now $settings has everything from the user_settings table as an array echo '<form action=...>'. ' <input type="text" name="real_name" value="'.$settings['real_name'].'">'. ' … | |
Having hardly used macs in my life, I am now borrowing an old iMac 3G (OS 10.2.8 I think) to temporarily host some php files. I have downloaded the latest version of MAMP to get the job done and done the whole unzipping/moving to apps folder thing. My problem comes … | |
Re: You need to post the relevant code for anyone to know what's going on. Is the code that checks the input data and the code that displays the input boxes on the same page? Does refreshing/reloading the page allow you to retry? | |
Re: a variable (such as [icode]$myusername[/icode]) must be set [i]in the same script[/i] for it to have a value, and thus be echo'd to the page. This means the value will be lost if the user refreshes the or follows a link. The [icode]$_SESSION[/icode] is a special array that will hold … | |
Re: How is your database set up? That will only work if 1. postid is unique to each post and parentid holds the id of the parent post and NULL if it is itself a parent post. OR 2. parentid is set to the id of the topic for the parent … | |
Here's my predicament. I Have managed to send and retrieve some HTTP requests using the GET method successfully using the following code: [code=php] function send_to_host($host,$method,$path='/',$data='',$useragent=0){ // Supply a default method of GET if the one passed was empty if (empty($method)) { $method = 'GET'; } $method = strtoupper($method); $fp = … | |
Re: Using any program that can use sockets you can do this. If you have php installed on your computer then that's easy. I have done it with Game Maker (using 39dll) before. What you need to do is read the file (word doc) into your program. (You may need to … | |
Re: See [URL="http://www.daniweb.com/forums/thread167986.html"]here[/URL]. | |
Re: Are you using a session to store the stuff in the cart or what? I'd suggest creating a session for the user with the following variables: array $quantity array $product each element of those arrays will contain the info for an item. ($quantity[0] has the quantity of the first item … | |
Re: As PHP is a server side language, PHP can't be used to modify the page once it has been sent to the browser. You need a client side language (that is executed by the viewers browser) such as Javascript to do what you are explaining. I haven't done much with … | |
Re: There are functions for including in a script, a script held in another file. Is this what you mean? i.e. you can define the functions that you will use (and constants, variables, etc) and then [URL="http://au2.php.net/include/"]include [/URL]them. Syntax: [code] include 'functions.php'; include "variables.inc"; [/code] See also, [URL="http://au2.php.net/include_once/"]include_once[/URL], [URL="http://au2.php.net/require/"]require [/URL]and [URL="http://au2.php.net/require_once/"]require_once[/URL]. | |
Re: Ok, you need to look at a few tutorials (there's millions on the net) about user logins and sessions. In a nutshell: [ICODE]form.html[/ICODE] This contains the textbox. [code=html] <form action="submit.php" method="GET"> <!--or "POST"--> <input type="text" name="username" /> </form> [/code] [ICODE]submit.php[/ICODE] Set the session variable [code=php] <?php session_start(); //so you can … | |
Re: @bappaditya Are you saying "www1" is to www1.example.com as "mail" is to mail.google.com? Does this mean that "www" a subdomain but many modern web servers are able to assume a subdomain of "www" when none is given? (because "www.mail.google.com" doesn't give a response) Thanks for clarification. | |
Re: first, after $find_ad has been set, I would split the data by [icode]$list = explode("</tr>",$find_ad)[/icode] then do a replacement on each item like so: [code=php] $list=preg_replace("/([^>])(</a> \(\d{4}\))/",'\1\2 - <a href="http://www.theflickzone.com/search.php?do=process&sortby=lastpost&titleonly=true&query=\1"> Search </a>',$list); //then to wrap it up: $new_page = '<table border="1" cellspacing="0" cellpadding="4" style="margin-right:30px;">'; foreach ($list as $item){ $new_page .= … | |
Re: To have less of an impact on the server at runtime I'm guessing 2) would be much better as in 1) you must load the entire history of news items into memory as opposed to about 30 bytes per news item. (Have I interpreted you correctly?) | |
Re: Ok, first off I'd direct my form to a page of my own, say "submit.php", which would store the data passed to it into the database and then (before echoing any data to the page) use header() to redirect the user to the api url. I'm assuming you know ho … | |
I've got a bit of a question regarding the <col> tag and how it takes style attributes in Firefox and Internet Explorer. Here's my code: [code=css] /* * This is the global style sheet for Humbug's test site. Every page will link to it. * Copyright Ben Ritter 2008 */ … | |
Re: Unless you are using someone else's stuff in your game you should be fine with copyright. Careful submitting your game to certain sites as you might be giving them copyright permissions that you don't want to. It should also be pretty easy put something in the credits saying where the … | |
Re: [QUOTE=Ancient Dragon;627788]Why do you need more than 30 minutes to edit your post? It seems to me that 5 minutes should be pleanty of time to correct typing or other errors. But I suppose more than 5 minutes might be needed by people who hunt-and-peck at the keyboard.[/QUOTE] There's a … | |
Re: What exactly are you asking for? What is a word "we like"? It will probably be possible to write a function to do what you want but I'm not entirely sure what that is. All in all, what info do you want to get out of the function and what … | |
Re: I have just written a script to do just that. I used [URL="http://au2.php.net/manual/en/function.ereg.php"]ereg()[/URL] to do a search for a regular expression that will verify a valid entry. e.g: [code=php] if (!ereg('^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]$', $date)){ //I got an error when I used "[0-9]{2}" instead of "[0-9][0-9]" //^ matches start of string and $ … | |
Re: You could store the number in either a txt file (if you don't want to do the mysql connection thing just for it) or in a db and also store the date/time for which that number "expires" and it should be incremented. Then every time a user views the page … | |
Re: [icode]"^(http://|https://)?(www\.)?([a-zA-Z0-9-]+\.)*([a-zA-Z]+)\.(com|net|org|co\.uk|com\.au|tv|biz|etc)(/|$)" [/icode] should work (as a pattern) and will return false for invalid URL's. The domain will be in $4. If you know you have a valid URL and you can assume that the domain is longer then 3 chars then you can use the simpler [icode]"([a-zA-Z0-9-]+)(\.[a-zA-Z]{2,3})+(/|$)"[/icode] which will leave … | |
Re: Here's a few mistakes in your code that I have spotted: [code=php] if($gender==all||$sercountry==all){ //should be: if($gender=="all"||$sercountry=="all"){ [/code] Here is how I would structure it: [code=php] <?php include"config.php"; $gender=$_POST['gender']; $sercountry=$_POST['country']; trim($gender); trim($sercountry); if(!$sercountry || !$gender){ //fail echo "<font color=brown><b>You have not entered ALL search details.<b></font>try again</b></font>"; exit; } if($gender=="all" || $sercountry=="all"){ … | |
Re: Personally, I would make a few tables like this: (I will refer to email's (eg [email]someone@example.com[/email]) as emails and messages between users as Personal Messages (PM's) table: users [CODE] Column: description id: unique, auto increment id of user username: username password: hash of password email: users email address[/CODE] table: PMs … | |
Re: So you want to physically print the contents of receipt.txt? What method are you using to print the first line? | |
Re: Well your looking at one right now... I don't know if you will find many sites that will give you their php source code but you can look at tutorials to find out how to do specific things and get a general idea of what method certain sites are using … | |
Re: [url]http://www.tizag.com/mysqlTutorial/index.php[/url] Have a look through that (there's a lot there so just make sure you get what you need). One thing, with your code: [icode]define ("PAGE_TITLE", "Properties for sale in $record[countryname]");[/icode] You should have: [icode]define ("PAGE_TITLE", "Properties for sale in $record[[COLOR="Red"]'[/COLOR]countryname[COLOR="Red"]'[/COLOR]]");[/icode] That will work if the array $record has an … | |
Re: [CODE=php]echo " </tr>\n"; echo " <tr>\n"; echo " <td class=\"hotelinfotext\"> if ($row[NonSmoking] == 1) { echo 'Non smoking rooms available, '; } if ($row[AirCon] == 1) { echo 'Air conditioning, '; } if ($row[Restaurant] == 1) { echo 'Restaurant, '; } </td>\n"; echo " </tr>\n"; [/CODE] You are echoing you … | |
Re: I don't understand what your asking... | |
Re: Wow, that's kind of confusing. What do you mean by a dictionary? No one here will write your code for you but we will point you in the right direction. [URL="http://www.tizag.com/phpT/"]Here[/URL] is a good place to start (you'll want to make sure you look at the "POST & GET" section). … | |
Re: Did you actually use "http://xx.xx.xxx.xxx/..." as $fullpath? Because I've got a feeling that wouldn't work. [icode]if (file_exists($fullpath))[/icode] is being used remember, and by the look of it is returning FALSE. Also, [icode]http%3A%2F%2F69.80.208.156/birkeys/phpThumb.php[/icode] is a bad href. As php will see all the characters in the URL as literal anyway, you … | |
Re: One method you could use is to create the site with english coding (so you can read it) but leave all the words that are to be displayed on the screen in foreign places such as .txt files that you can include. I would then store these in separate folders … | |
Re: Why the [icode]$result = mysql_query($query);[/icode] on the fourth last line? You don't need the [icode]$result =[/icode] on that line as the mysql_query will return [icode]TRUE[/icode] on success. You are then treating this as a MySQL result resource in [icode]mysql_fetch_array($result)[/icode] (because the expression in the why loop is executed every time … | |
Re: What buddylee said. What does the source to your page look like? It's probably not correct at all but IE happens to display it correctly. You need something like this: [code=php] echo '<table>'; while ($row = mysql_fetch_array($result)){ //loop through the rows echo '<tr>'; foreach ($row as $element){ //loop through elements … | |
Re: You will need to use something like Javascript of AJAX or something that can be run [i]client side[/i]. PHP is a [i]server side[/i] language that is executed on the server computer before the users web browser receives the html (which is why you never see php code when you view … | |
Re: What does the script output as it is? Personally, since you have a [icode]$counter[/icode] variable I would do the following to retrieve the data that was POSTed to the page: [code=php] if (isset($_POST["submit"])) { $count = $_POST['counter']; $items = array(); //each element has another array inside it for ($i=0; $i<$count; … | |
Re: Wow, what's with all the {}'s and the .tpl file? is there something about PHP that I'm missing? I haven't come across anything that looks like that before. | |
Re: This is the first thing I've spotted (as you can see, the whole things inside the quotes): [code=php]echo "<tr bgcolor=\"' . $bg . '\">\n";[/code] this will echo: [icode]<tr bgcolor="' . #ffffff . '">\n[/icode] (where #ffffff is the contents of $bg) What you want is: [code=php]echo "<tr bgcolor='" . $bg . … | |
Re: Ok, first off, W3schools recommend you use [icode]<input type="submit" ... />[/icode] tags inside forms for consistency across browsers. [url]http://www.w3schools.com/tags/tag_button.asp[/url] (And what's with the [icode]</n>[/icode] tag?) So what exactly are you trying to achieve? Do you want the image next to the checked radio button only or just to the right … |
The End.