Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. How are you using the code I suggested? Post all your code in full here
  2. No matter how many entries of the same group in the table I cannot reproduce your issue. Everything is adding up correctly. The only thing I don't understand is in some rows the dsa_awnser column has text and some has numbers. Can you post the code you're using here in full
  3. Umm, this $lines = explode(', ', $line); echo $line[0]; should be $item = explode(', ', $line); echo $item[0];
  4. 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
  5. da and d a are aliases to des_awnsers and des The blue bits are the table names, the bits in red are the aliases (or shortened names for the tables)
  6. 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
  7. Switch the last two lines in your foreach around.
  8. 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.
  9. 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>'; }
  10. 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.
  11. 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; }
  12. 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.
  13. 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"/>
  14. 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?
  15. 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 ' />'; }
  16. $username = $_POST['username'] . '@domain.com'; $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$username.'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl'];
  17. 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; }
  18. Have a read of this FAQ post
  19. 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.
  20. 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.
  21. 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.
  22. Change this foreach($_POST['delete'] as $value) { $list+="'$value$'"; if($counter>0) $list+=","; $counter++; } To just $list = implode(', ', $_POST['delete']);
  23. The $_SERVER superglobal maybe? echo '<pre>'.print_r($_SERVER, true).'</pre>';
  24. 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.
  25. You only need to restart IIS not the whole server. Restarting IIS shouldn't affect your users.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.