wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
[SOLVED] Functions with unlimited arguments
wildteen88 replied to DeanWhitehouse's topic in PHP Coding Help
yes that is fine. However for readability, it'll be better to construct your array before calling the function (as I have shown). Rather than construct the array when you call the function. -
Help displaying my form results on the same page
wildteen88 replied to dthomas31uk's topic in PHP Coding Help
If you want to the form to submit to itself then done set an action. Or use the following <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> -
Does this apply to all $row variables? Or just certain ones?
-
[SOLVED] Functions with unlimited arguments
wildteen88 replied to DeanWhitehouse's topic in PHP Coding Help
You could use function_get_args(). Have a look at the example from the manual. Alternatively just pass an array to your function, eg $arr = array('one', 'two', 'three'); function make_list($arr) { if(is_array($arr)) { $list = '<ol>'; foreach($arr as $item) $list .= '<li>'.$item.'</li>'; $list .= '</ol>'; return $list; } return false; } echo make_list($arr); -
if you're using PHP5 then you could use stripos
-
[SOLVED] A Little Help index.php?Page=Home
wildteen88 replied to ow-design's topic in PHP Coding Help
I'm not here write scripts for you. I'm here to help/guide you. You said earlier With that being said, you should know how to pull data from a databased on any type of column. -
[SOLVED] A Little Help index.php?Page=Home
wildteen88 replied to ow-design's topic in PHP Coding Help
You don't need to do that. mysql_fetch_assoc returns an associative array of columns. Just save each item of the array to a variable. Then do what ever you want with the variables. $row = mysql_fetch_assoc($result); $title = $row['title']; $content = $row ['content']; echo ' <h1>'.$title.'</h1> <p>'. $content . '</p> '; -
[SOLVED] A Little Help index.php?Page=Home
wildteen88 replied to ow-design's topic in PHP Coding Help
Woops, My bad -
When creating a new MySQL user account make sure you are allowing connections from localhost
-
[SOLVED] A Little Help index.php?Page=Home
wildteen88 replied to ow-design's topic in PHP Coding Help
As you normally would do. The extreme basics would be $title = $_GET['page']; $sql = "SELECT * FROM your_table WHERE title='$page'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo '<pre>'.print_r($row, true).'</pre>'; -
It as safe as the original url. All you're doing is making your urls cleaner. You still need to sanitize your data as you would normally. As for why its not working remove the caret symbol ^ from your rewrite rule: RewriteRule /products/([0-9]+) /products.php?id=$1
-
Updating PHP on Windows (with TSW) . . . how?
wildteen88 replied to WebGyver's topic in PHP Installation and Configuration
It depends on how TSW has configured PHP. You should be able to just download the latest zipped binaries package for PHP5 from php.net and extract the contents of the zip to where PHP is currently installed (overwriting existing files/folders). This should upgrade PHP. But seeing as TSW is a pre-configured package of other software this may be easier said than done. This is the problem with all-in-one packages such as XAMPP, WAMP, TSW etc. They limit you to what you can do when upgrading certain components. I always prefer a manual install myself - especially for a live site. That way if things go wrong I know how to sort it out and know that upgrading any component wont break another. -
This is archived using mod_rewrite
-
pass multiple url variables using OR operator
wildteen88 replied to mishasoni's topic in PHP Coding Help
When comparing variables use == not = $search = null; if(isset($_GET['firstletter'])) { $firstletter = $_GET['firstletter']; if($firstletter == 'UVW') { $search = " AND NameLast LIKE 'U%' OR NameLast LIKE 'U%' OR NameLast LIKE 'V%' OR NameLast LIKE 'W%'"; } elseif($firstletter == 'XYZ') { $search = " AND NameLast LIKE 'U%' OR NameLast LIKE 'X%' OR NameLast LIKE 'Y%' OR NameLast LIKE 'Z%'"; } elseif(in_array(strtolower($firstletter), range('a','z'))) { $search = " AND NameLast LIKE '$firstletter%'"; } } $query_rsParticipants = "SELECT * FROM Contacts WHERE ContactType = 'Scientist' AND ContactID_pk <> 0". $search ." ORDER BY NameLast ASC"; -
You cannot have any form of output before the use of session_start() You should do: <?php error_reporting(E_ALL); ini_set('display_errors','1'); session_start(); if(!isset($_SESSION['loggedin'])) { header('Location: http://www.xxxxxxxxxxx.com/'); exit(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
Whats on line 2 in admin.php?
-
You can use glob() for that foreach (glob("users/*.txt") as $userfile) { echo "$userfile<br />"; }
-
Is the password always going to be on the second line? if so you could do $lines = file('michael.txt'); $lines = array_map('trim', $lines); // update the second line. $lines[1] = 'password = new_password'; // update the file. file_put_contents('michael.txt', implode(PHP_EOL, $lines));
-
free hosting - not sure what it would come under?
wildteen88 replied to ghqwerty's topic in Miscellaneous
You should get in contact with your host about this. -
The problem I see is you're two different function sets, you use mysqli_query however you use mysql_fetch_assoc Your cannot use mysqli_* functions and mysql_* functions together. They are not compatible.
-
NO! It should be TEXT. Woops. This: $query = "INSERT INTO attacks SET username='$user',log='$logs2', data='$data'"; mysql_query($query) or die("Error: ".mysql_error()); Should be $query = "INSERT INTO attacks SET username='$user',log='$logs2', data='".mysql_real_escape_string($data) . "'"; mysql_query($query) or die("Error: ".mysql_error());
-
This is most probably because you're using the incorrect data type for the data field in your database. Make sure you're using TEXT not VARCHAR
-
Add all your times in an array eg $times = array('0900 - 0930', '0930 - 1000', '1000 - 1030', etc ); Now when you retrieve the time from your database you'll do $time_key = 3; if(isset($times[$time_key])) { $time = $times[$time_key]; }
-
<?php // everything get saved to the $data variable $data = null; $logs1 = "$warresult<br><br>BATTLE REPORT:<br>Your total AP: $totaltotal <font color=#FF0000>($el% losses)</font><br>Enemy total DP: $etotaltotal <font color=#00FF00>($ul% damage)</font><br><br>"; $data .= $warresult."<br><br>BATTLE REPORT:<br>Your total AP: ".$totaltotal." <font color='#FF0000'>($el% losses)</font><br>Enemy total DP: ".$etotaltotal." <font color='#00FF00'>($ul% damage)</font><br><br>"; $unitnames = array("T80","BMP","Mi-28","AH-64","RAH-66","F-16","F-117","F-22","B52","B2","ICBM","BML Submarine","Nuclear Missile","".$info[107].""); $unitnamese = array("T80","BMP","Mi-28","AH-64","RAH-66","F-16","F-117","F-22","B52","B2","ICBM","BML Submarine","Nuclear Missile","".$enemydet[107].""); $j = false; for ($i = 0; $i < 13; $i++) { if ($elosses[$i]) { if (!$j) { $data .= "You killed:<br>"; $j = true; } $data .= "<a class='variable'>".$elosses[$i]."</a> enemy ".$unitnamese[$i]."s<br>"; } } $data .= ($j) ? "<br>" : "You killed <a class='variable'>0</a> enemy units<br><br>"; $j = false; for ($i = 0; $i < 14; $i++) { if ($losses[$i]) { if (!$j) { $data .= "You lost:<br>"; $j = true; } $data .= "<a class='variable'>".$losses[$i]."</a> ".$unitnames[$i]."s<br>"; } } $data .= ($j) ? "<br>" : "You lost <a class='variable'>0</a> units<br><br>"; $data .= "<br><br>"; // display whats stored in the variable echo $data; // add data to database $query = "INSERT INTO attacks SET username='$user',log='$logs2', data='$data'"; mysql_query($query) or die("Error: ".mysql_error()); ?> Something like that? You'll need to change your query though. I dont know you table structure.