wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Umm, this $lines = explode(', ', $line); echo $line[0]; should be $item = explode(', ', $line); echo $item[0];
-
When joining tables I always place the table name in front of the field names. This makes the the query neater and easier to understand. I use aliases to shorten the table names, I normally use the tables initials or just the first two characters of the table name when using aliases. Hope that clears things up. I have tested my query again with the sample data you provided and the query does not multiply the sum of desc_awnser by the number of rows. What data type have you set the desc_awnser field to in table scheme? It should be set to INT or something similar
-
Umm, I tested the query and it works fine. I setup four records in the des_awnsers table like, so id | _group | weight | desa_answer 1 | 115 | 5 | 10 2 | 115 | 5 | 20 3 | 135 | 5 | 20 5 | 135 | 5 | 30 And the des table like so id | _group | maxscore 1 | 115 | 30 2 | 135 | 50 The result I got from the query id | _group | weight | total | maxscore 1 | 115 | 5 | 30 | 30 2 | 135 | 5 | 50 | 50
-
Switch the last two lines in your foreach around.
-
Your code just defines a few variables and two functions. Without calling any of the functions nothing will happen. Judging by your code it looks like you need to call the sub_include() function for anything to happen.
-
You should just use one query $sql = 'SELECT da._group, da.weight, SUM(da.desa_answer) AS total, d.maxscore FROM des_answers da INNER JOIN des d ON d._group = da._group GROUP BY da._group ORDER BY da._group ASC'; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { echo '<pre>' . print_r($row, true) . '</pre>'; }
-
You'd want to add the following line within you foreach loop after the echo. $item = explode(', ', $line); Now you can do this within your loop echo $item[0]; To display the lastName from the current line, echo $item[1]; will return the firstName, echo $item[2]; will return the address etc.
-
You're using case wrong, but case null: should work. switch only compares the value of the variable you pass it. It does not allow you perform any conditions. $var = null; switch($var) { case null: echo '$var is NULL'; break; case '': echo '$var has no value or is emtpy'; break; }
-
Do you mean view source? You cant do this with PHP. You have to use a client side language such as Javascript. However there is no point in disabling right click > view source as it very easy to work around and doesn't add any protection. You'll just end up irritating your visitors.
-
Really simple question about a form and $_POST vars
wildteen88 replied to Perfidus's topic in PHP Coding Help
You have invalid HTML. You're not setting the type for the inputs. This is the correct way <input type="text" id="cemail" name="cemail"/> This is not <input id="cemail" name="cemail"/> -
It should do. What does the generated url look like? Change $username = $_POST['username'] . '@domain.com'; $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$username.'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl']; to $username = $_POST['username'] . '@domain.com'; $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$username.'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl']; echo $redirectlocation; exit; Is the url formatted correctly?
-
All you need to do is to loop through the array of $images to regenate the <img /> tag, like so foreach($images as $image) { echo '<img'; foreach($image as $attr_name => $attr_value) { echo " $attr_name=\"$attr_value\""; } echo ' />'; }
-
$username = $_POST['username'] . '@domain.com'; $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$username.'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl'];
-
As I see it you can do away with the switch/case completely. You can just do this instead: switch($type) { case 'weapons': $name = mysql_real_escape_string($_GET['name']); $sql = "SELECT * FROM weapons WHERE weapon_short_name = '$name'"; $result = mysql_query($sql); if(mysql_num_rows() == 1) { $InfWeap = mysql_fetch_assoc($result); echo "Full Name: " . $InfWeap['weapon_name'] . "<br>Short Name: " . $InfWeap['weapon_short_name']; } else { echo 'Weapon not found!'; } break; }
-
Have a read of this FAQ post
-
There is no problems with that script. Your code works fine. However I do not see the point in doing <?php // some php code here ?> <?php // some more php code here ?> If you're not going to put anything between the code blocks then there is no need to go out of php and then immediately back in to php.
-
[SOLVED] PHP-IIS coding problem
wildteen88 replied to johnojohnson's topic in PHP Installation and Configuration
Personally I'll keep all files that came with PHP in the PHP installation folder, eg C:/PHP You should then add the PHP folder to the PATH and PHPRC Environment Variables. Restart your computer and PHP should read the php.ini located in your PHP Installation folder. -
Has anyone heard of/used... XAMPP?
wildteen88 replied to maat's topic in PHP Installation and Configuration
It is up to you how you setup the AMP stack (Apache, PHP and MySQL). If you want AMP to be setup quickly with worrying about configuration then use XAMPP. However I do recommend you to install Apache, PHP and MySQL separately. -
Change this foreach($_POST['delete'] as $value) { $list+="'$value$'"; if($counter>0) $list+=","; $counter++; } To just $list = implode(', ', $_POST['delete']);
-
[SOLVED] PHP-IIS coding problem
wildteen88 replied to johnojohnson's topic in PHP Installation and Configuration
In a new script run phpinfo() Make sure php is reading the php.ini you're editing by looking at the Loaded Configuration Path line. This should state the full path to the php.ini PHP is reading for configuration. If its not there is your problem. -
[SOLVED] PHP-IIS coding problem
wildteen88 replied to johnojohnson's topic in PHP Installation and Configuration
You only need to restart IIS not the whole server. Restarting IIS shouldn't affect your users.