wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
One problem I see is your field names contains spaces and are far too complicated. You should not have spaces within your field names and you should keep your field names simple, for example name="email" is much simpler than name="Email Address" Also for gender you should use radio buttons rather than checkboxes. For the gender I'd do: <td>Gender:</td> <td> Male <input type="checkbox" name="gender" value="male" /> Female <input type="checkbox" name="gender" value="female" /> </td> In PHP you'd use $_POST['gender'] to retrieve what the user selected. But yeah we'll need to see you PHP code in order to help you.
-
Do you mean you're wanting to read the contents of the text file into a variable? Is so you can use file_get_contents or use fopen, fread and fclose
-
getting form field values before pressing the submit button
wildteen88 replied to anamika65's topic in Javascript Help
This is not possible with PHP alone. You'll need to use a client side language such as Javascript using the XMLHTTPRequest object (AJAX). Search google for some AJAX tutorials. -
[SOLVED] multidimension array using mysql database
wildteen88 replied to project-nz's topic in PHP Coding Help
$row will only be a single dimensional array. You cannot return a specific row in this way. However you can with mysql_result -
You have an error with your query. Change $mysql_stuff = mysql_query($query, $mysql_link); to $mysql_stuff = mysql_query($query, $mysql_link) or die(mysql_error());
-
Sorry I mis read your code earlier. I thought you was using range at the time. rand() returns a number between 1001 and 9999. To break the number into ones, tends, hundreds, thousands I came up with this: <?php $x1 = (string) rand(1000, 9999); $fields = array('ones', 'tens', 'hundreds', 'thousands'); $digits = str_split($x1); echo '<p>The number: '. number_format($x1, ',') .'</p>'; ?> <table border="1" cellspacing="1" cellpadding="10"> <tr> <?php foreach($fields as $field) { echo '<th>'.ucwords($field).'</th>'; } ?> </tr> <tr> <?php foreach(array_reverse($digits) as $num) { echo '<td>'.$num.'</td>'; } ?> </tr> </table>
-
Are for arrays you use a different syntax, $x1 = rand(1001,9999); for($i = 0, $j = count($x1)-1; $i < $j; $i++) { echo $x1[$i]; }
-
Yes that is achievable, however this method will only work with strings. Why are you wanting to store each digit within a separate variable?
-
$_SESSION variable question.. not correct when used?
wildteen88 replied to A JM's topic in PHP Coding Help
This is typical Dreamweaver gunk. However it basically used to make data that goes into a query safe for insertion. -
You can access each individual character within a string using this $string = '12345'; echo $string{3}; // get the 4th character echo $string{1}; // get the 2nd character echo $string{4}; // get the 5th character Alternatively you can use a loop: for($i = 0, $j = strlen($string); $i < $j; $i++) { echo $string{$i}; }
-
[SOLVED] echoing <div> tags in if statements.
wildteen88 replied to seany123's topic in PHP Coding Help
This line echo "</div></div>;\";"; should be outside of your last if statement. if($player->hospital >= 1 || $player->prison >= 1 || $player->news >= 1) { echo "<div class=\"g_content\"><h3> Notifications</h3><div class=\"g_text\"><center>"; if($player->hospital >= 1) { echo "<a href=\"../hospital.php\">You Are In Hospital [\" . $player->hospital . \"mins left]</a><br>"; } if($player->prison >= 1) { echo "<a href=\"../prison.php\">You Are In Prison [\" . $player->prison . \"mins left]</a><br>"; } if($player->news >= 1) { echo "<a href=\"../news.php\">You have unread News</a><br>"; } echo "</center></div></div>"; } -
You'd use the S modifier.
-
[SOLVED] echoing <div> tags in if statements.
wildteen88 replied to seany123's topic in PHP Coding Help
You need to escape the double quotes within your strings. Otherwise PHP will think you're ending the string early -
The problem is do with empty selected="" attributes. You should only echo "selected="selected" for <options> that should be selected, the remaining <options> should not have a selected attribute. This would be the correct way: <select name="gender"> <option value="Male"<?php if ($player->gender == 'Male') echo " selected=\"selected\"";?>>Male</option> <option value="Female"<?php if ($player->gender == 'Female') echo " selected=\"selected\"";?>>Female</option> <option value="Other"<?php if ($player->gender == 'Other') echo " selected=\"selected\"";?>>Other</option> </select>
-
Have a look at radi8's post above. Change $_POST['ogender'] with $player->gender
-
You should look at the 3rd tutorial MatthewJ linked to in his post. That use a flat file database (just a plain text file) to store the hits.
-
new lines are added to the database. Its actually your browser which does not display them. When displaying data from your database that has new lines. You should use nl2br to convert them into HTML line breaks (<br />).
-
Yes your problem is to do with the square brackets. What is '[NT]cartoon' ? Is that someone username from your site? I wouldn't recommend naming your checkboxes with peoples usernames. You should name your checkboxes as users[] then just pass their username as its value. When you process your checkboxes do foreach($_POST['users'] as $user) { echo $user .' was selected<br />'; // do what ever here }
-
Need help checking if $_POST filed is empty
wildteen88 replied to Beauford's topic in PHP Coding Help
PHP sees zero with two meanings an integer and a boolean (false). You should also note that all $_POST data are strings. So if you want to see if the user only entered a zero in the field use if($_POST['pfor'] == '0') or type cast $pfor = (int) $_POST['pfor']; if($pfor === 0) -
the second parameter requires a UNIX timestamp. Use strtotime to convert $date to unix timestamp
-
Any reason you're floating your table to the right?
-
Shouldn't you be using overflow:hidden. Using overflow: auto will cause scroll bars to appear.
-
This will be a HTML/CSS issue. Nothing to do with PHP.
-
Make sure you are calling session_start before you include navmenu.php. Remember before you use $_SESSION variables you need to start the session first. Example <?php session_start(); // some other code here include("navmenu.php"); ?>