denno020
Members-
Posts
761 -
Joined
-
Last visited
-
Days Won
3
Everything posted by denno020
-
loop through SQL results to print an HTML table
denno020 replied to jasonxxx102's topic in PHP Coding Help
Don't you have to call execute() on $con? I don't know what $con is so I don't know what method you're using.. -
You need to look into adding a 'Login with Facebook' link to your site (php application). To do this, you will need to create an application on Facebook, which will give you access keys to talk between Facebook and your php application. Then using the Facebook php class, you can interface between a user who clicks on the 'Login with Facebook' and your application, grabbing their basic public information, as well as anything that you have specifically requested when setting permissions for your Facebook application. Hopefully that gets you heading in the right direction. Denno
-
How do I pull array from API into database?
denno020 replied to jbass350z's topic in PHP Coding Help
What code snippets have you tried already? Post some here and tell us where you think they're going wrong, or if they're just completely not working, and I, or someone else, will guide you through why. -
I suppose you could store the company names in a text file instead, each name on a new line. Then read in that text file into an array using the php function file(). Then you can loop through the variable that you assigned that to, and include all the files. I think that would work.. $names = file("names.txt"); foreach ($names as $name) { include "../".$name."/rest/of/path"; //Put your correct amount of ../ here }
-
This would usually be done with a database that would store values like; when the timer was started, if the timer is paused, (and if paused) when the timer was paused. Without the use of a database, I guess you could use a cookie or localstorage to store those same values. When your page loads, look for that information and have the timer set itself accordingly.. Hope that gets you on the right track Denno
-
$show_path = new FileStorage(); echo $show_path->FileStorage($path); That should work.. Make sure you do it outside the class definition, or inside another function within that class that is called externally. Hopefully that helps Denno
-
Getting a strange error message, can't solve it.
denno020 replied to Filip's topic in PHP Coding Help
The error is telling you that there is an unknown variable being used, kunder, aka $kunder. If you look on line 16, you will see that you're trying to access $kunder as an array, however $kunder is not initialised anywhere, and therefore, is undefined. Denno -
It looks like it's told you already what you need to do.. Without looking at your code, I would assume you're doing something like this: $arr = array( /* lots of data*/); echo json_encode($arr); The error message is asking for the header, so on the line directly before your echo, you need to add header('Content-Type: application/json'); Hope that helps. Denno
-
Depends on what you mean by 'link them into one variable'. //You can add/subtract/divide/multiply them all, as suggested by kadeous $wholenumber = $number1 + number2 + $number3 + $number4; $wholenumber = $number1 - number2 - $number3 - $number4; $wholenumber = $number1 / number2 / $number3 / $number4; $wholenumber = $number1 * number2 * $number3 * $number4; //You can concatenate them $wholenumber = $number1 . $number2 . $number3 . $number4 //You can put them into an array $wholenumber = array( $number1, $number2, $number3, $number4 ); Those are three very basic things that you could do to 'link' them, which is all we can really suggest without more information as to what you actually want Denno
-
This is wrong //Writes the information to the database mysql_query("INSERT INTO band (Name,website,Description,timestamp,photo)") VALUES ('$Name', '$website', '$Description', '$timestamp','$photo') ; This is right //Writes the information to the database mysql_query("INSERT INTO band (Name,website,Description,timestamp,photo) VALUES ('$Name', '$website', '$Description', '$timestamp','$photo')") ; You'll notice that you put the double quote and bracket in the wrong place...
-
I'm not sure if it's just a problem with copying and pasting your code here, but can you see in your PHP, the highlighting isn't working correctly.. That is because you've missed a closing double quote and ending bracket.. Look at your mysql_query(...... line, and find where you're missing the required characters. Denno
-
I'm curious, what do you use to code in? If you used any sort of IDE, then you would see that you have a syntax error. Using the curly braces around php functions in a string won't work, you need to concatenate the function inside the string. Refer to the fixed code below echo "<tr bgcolor=\"#333333\"><td><p><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\green\"><b>{$band['Name']} - Review Posted: ".date("F j, Y g:i a", strtotime($band["timestamp"]))."</b></font></tr>"; That should fix your problem. As for there not being an error number, 500 Internal Server Error is an error number.. Denno
-
array parsing to variable from echo/print response
denno020 replied to airborne305's topic in PHP Coding Help
Tp print 'address' and 'pubkey', you will access it like this: $apple[0]['address'] $apple[0]['pubkey'] Your variable $apple is an array, with 1 element, which is another array. That array then has all of your values, so that's why you need the '[0]' before the index of the value you want (as array's are 0-indexed, meaning the first value is always at position 0, second value at position 1, and so on). Hopefully that helps you out. Denno Edit: I just read through all of your code (instead of just looking at the print_r result), to avoid the need of the [0], then change: $apple = array ($service->validateaddress("1234567890")); //to $apple = $service->validateaddress("1234567890"); Then you access the values like this: echo $apple['address']; echo $apple['pubkey']; -
You need to see what the action of your form is. Easiest way to do that would be to view the source of the page once it's loaded, then debug back from there. Also, in your description you say you want to go to forum.php, however in the first part of the if statement for settings $forumurl, you've got forum.html there. Denno
-
Php won't return values whilst the script is still executing. Only at the end will any output actually be sent. So your echo will only be echo'ed at the end of the script processing, as per your findings. The way you would do a progress bar (at least the way I think you do it, as I've not actually done it myself), is to also use cURL. Denno
-
Well from the Twitter images, it looks like you want the semi-transparent background? Opaque means you can't see through it, so either I'm confused as to what you want, or you're confused on the meaning. Anyway, if you want the partially transparent background, then a very simple way to do it would be to give the div a background colour of white using the rgba setting: #div { background-color: rgba(255, 255, 255, 0.5); } The 0.5 means it's 50% transparent. That will allow some of the background to show through, while still allowing the text to be read fairly easily, however you will have to play with the values to find the right balance. Hope that helps, Denno
-
Have you tried adding background-size: cover; see http://css-tricks.com/perfect-full-page-background-image/ Hope that helps, Denno
-
If it only displays once, when you first login, and then never again, you will most likely want a database table which will store the ID's of users who have 'seen' the special offer. When your page loads, query the database, see if the user is in the table already, if not, use whatever method to like to display the special offer. If you choose to use javascript to animate a dialog (or whatever), then you will need to set a flag somewhere in your HTML that the javascript can check when the DOM is ready, which will indicate to the javascript to perform the code that will show the special offer. Hope that helps, Denno
-
What are some practical uses for callback functions?
denno020 replied to CrimpJiggler's topic in PHP Coding Help
Unlike when you execute php on the command line, output is only output once, at the end of the script execution. So when you execute your script, it will place all of your echo's into the output buffer, and then when the script has finished, it will then put print the output buffer to the screen. -
The reason is when you submit the form, $arrayIndex is populated with another random answer, because the script is run again from the start. What you need to do is store the answer some other way, and check against that. You can used a session variable for that. Also, move the answer check to the beginning of the script, so the first thing that it does is check for a submit. See the following: if (isset($_POST['submit'])) { if ($_POST['answer'] == $_SESSION['answer']) { echo "correct"; } else { echo "incorrect"; } } else { echo "Answer this:"; } $question = array( 0 => array( 'question' => "1+1=", 'answer' => 2 ), 1 => array( 'question' => "2+1=", 'answer' => 3 ), 2 => array( 'question' => "4+1=", 'answer' => 5 ) ); $arrayIndex = array_rand($question); $q = $question[$arrayIndex]['question']; $a = $question[$arrayIndex]['answer']; $_SESSION['answer'] = $a; print $a; print (" <form method='post'><br/> <input type='text name='" . $a . "' value='" . $q . "'> <input type='text' name='answer'><br/> <input type='submit' name='submit'><br/> </form> "); Denno
-
the html_table macro is expecting strings in a single array. You can achieve it like this: Your $table array needs to be a single array, with all of the elements that you want. Then in your smarty template, you tell the macro how many columns there are to be in the table, lets use 5 as an example. Smarty will then take the first 5 elements in the array, and print them in the first row, it will then print the next 5 elements on the next row, and so on. The trick with your table is that you will have empty strings in your array, which will be taking up the extra columns in the table for rows that have less fields. Have a crack at that and let us know how you go, if you need more help, come back with the code you've tried . Denno
-
Assuming that the field 'games played' represents that number of games that player with name 'name' played in the given year, set in the 'year' field, then you could do a simple SELECT COUNT() for each field that you need tallies for. This would obviously mean that for each player that's played more than one year, they'll have their name in the database more than one time. Usually the best idea would be to have the name in there only once, by normalizing your databases (I think it's called), to separate data out into related tables..
-
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean
denno020 replied to yoyo's topic in PHP Coding Help
Looks like your query has failed for some reason. Hence why a boolean (false) is being passed to mysql_fetch_array -
This is how I thought it had to be done: $assets = array(); $assets[] = array( 'locationID' => $row['locationID'], 'itemID' => $row1['itemID'], 'typeID' => $row1['typeID'], 'quantity' => $row1['quantity']); But apparently it doesn't have to be done that way..
-
Are you getting any errors when you run this code? You haven't initialised $assets as an array, so php won't like you trying to append to the end of it with $assets[] = ...