Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Oh i got it, didn't assign anything to the prevlesson variable to start with so the first time it runs it thinks its a new lesson [code] <?php $result = mysql_query("SELECT * FROM kanji.kanji ORDER BY lesson ASC, kanji_id ASC") or die(mysql_error()); $x = 1; $prevlesson = ""; echo ' <table border="1"> <tr>'; $prevlesson = ''; while($row = mysql_fetch_assoc($result)){ echo ' <td align="center"><a href="explain.php?kanji_id=' . $row[kanji_id] . '">' . $row[kanji] . '</a></td>'; if ($row[lesson] != $prevlesson && $prevlesson != ''){//make sure prevlesson has some contentes while ($x <= 15) { echo "<td>&nbsp;</td>"; $x++; } $x = 1; echo ' </tr> <tr>'; } else { $x++; } $prevlesson = $row[lesson]; } echo " </tr> </table>"; ?> [/code]
  2. So llamaherder728 is your mysql username? If so there must be a clash in variables somewhere in your script. However, you said you were using the variable $db_user. Try taking out the variables for the connection and putting them straight into the mysql_connect function: mysql_connect('localhost', 'username','password'); mysql_select_db('dbname');
  3. There is a two part tutorial on here which you may find useful: http://www.phpfreaks.com/tutorials/107/0.php http://www.phpfreaks.com/tutorials/123/0.php
  4. Add an or die statement: $query = mysql_query("SELECT * FROM messages WHERE to = '".$_SESSION['username']."' AND read = 'no'") or die(mysql_error());
  5. Your IP address is changing because it is a dynamic IP address. Some people's stay the same and have static IP addresses. This is why any method getting a user's IP is unreliable.
  6. [code] <?php     $cc = 1;         print "<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse; margin-top: 15' width='100%'><tr>";               // Connect to Navigation database table mysql_connect('localhost','hidden','hidden'); mysql_select_db('noth_igbltduk');   $querycats = mysql_query("SELECT * FROM productcategories_comp ORDER BY id"); while($cats = mysql_fetch_array($querycats)) {     print "<td width='25%' valign='top'>     <table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='100%'>       <tr>         <td width='100%' valign='top'><center><b>".$cats['name']."</b></center></td>       </tr>       <tr>         <td width='100%' valign='top'><center><a href='".$ROOT."shop/".$cats['parent']."/browse.php?mode=".$cats['name']."'><img src='".$ROOT."shop/".$cats['parent']."/".$cats['thumb_img']."' border='0'></a></center></td>       </tr>     </table>     </td>"; if($cc ==4){ echo '</td><td>'; $cc == 1; }else{ $cc++; } } ?> [/code] I always find these things difficult to do without testing them, but try that.
  7. [code] <?php $result = mysql_query("SELECT * FROM `kanji` ORDER BY `lesson` DESC `kanji_id` DESC") or die(mysql_error()); echo '<tr>'; $x = 1; while($row = mysql_fetch_assoc($result)){ echo '<td align="center" >'; echo "<a href=\"explain.php?kanji_id=$row[kanji_id]\">$row[kanji]</a>"; echo '</td>'; if($row[lesson] != $oldlesson){ while($x <= 9){//add blank cells. 9 being the most in any one lesson echo '<td>&nbsp;</td>'; $x++; } $x = 1; echo '</tr></tr>'; }else{ $x++; } $oldlesson = $row[lesson]; } ?> [/code] Completely untested, but you could give it a wirl
  8. Im slightly confused as to how this would work. If each lesson is suposed to be an individual row in the table and contain cells for each kanji, aren't you going to end up with all the rows having differant numbers of cells because the number in each lesson varies?
  9. Like i said, remove the quotes: [code] <?php session_start(); if(empty($_SESSION['username']) or empty($_SESSION['id']) or empty($_SESSION['password'])) {//if there is nothing in the session echo 'you are not logged in'; exit;//quit the page so they cant view anything else }else{ echo 'You Are Now Logged In '; echo $username; echo '.'; include ('dbinfo.inc.php'); $sql_1 = "SELECT * FROM user_buildings WHERE username == '$username' AND password == '$password'"; $result_1 = mysql_query($sql_1); $num_1 = mysql_num_rows($result_1);//here $row_1 = mysql_fetch_assoc($result_1);//and here echo '<br><a href="buildings/mining_depot.php"><img src="images/buildings/mining_depot.png" alt="Mining Depot"></a>'; echo '<br>Level '; echo $row_1['mining_depot']; } ?> [/code] Ive no idea why/if it would cause a rogue character, but its certainly not correct to have these functions inside quotes
  10. If you specify no parameters for mysql_fetch_array() It returns both a numerically indexed and an associative array,for example, if you were to have a table with 2 fields, id and name, itwould return: $row[id]; $row[name]; $row[0]; $row[1]; This is obviously quite inneffiecent as it is larger and takes longer. With mysql_fetch_array you can specify to only return a numberically indexed array or an associative array. A numerically indexed array is the most efficient and quickest, but it can be hard to remember what all the numbers relate to. Using the parameter to return an associative array is basically the same as mysql_fetch_array(); Which is probably the best option for most people. So mysql_fetch_array() would return: $row[id]; $row[name];
  11. If you take a look at the tutorials over at www.ajaxfreaks.com when you have the time you'll find that its actually pretty easy to get started with ajax as its mostly cutting and pasting the javascript. It'll take a little time to get it to do as you want, but its pretty easy to start.
  12. Well i think it would actually be far quicker and easier from your point of you to have them submit it and generate it from there as the coding is far easier. But it might be more user friendly to use Ajax.
  13. Do you mean that you want to select a customer from a first field which is a drop down box and then it will populate the rest of the fields? If so, you have two options. You can either select the customer and submit a form and then retrieve the information based on that, or you can use ajax if you dont want to have a form submittal.
  14. I dont really see there is much differance between passing information and passing variables. I mean, you are going to need to send the contents of the variable, so you can send it to the php script either by post or get, and can retrieve any contents by manipulating the ouput of the php script and then manipulate the response with javascript.
  15. You can parse variables to and from PHP with ajax...
  16. http://uk.php.net/array_unique
  17. Err, i dont know much about actionscript, but is it possible to set up all of your php "functions" as individual files? And then simply link to them or something? Perhaps passing any information the functions require using GET?
  18. Err... [code] <?php $curr_month = date('n'); $curr_day  = date('j'); $curr_year = date('Y'); if(($curr_month ==6 && $curr_day >= 1) || $curr_month >6){ $last = $curr_year; }else{ $last = $curr_year - 1; } echo 'July 1 '.$last; ?> [/code] Untested, but should work
  19. Well, i *think* you do it using flush()... <?php for ($i = 0; $i<10; $i++){ echo " Line $i<br />"; flush(); sleep(1); } echo "Done."; ?> Run that and you will notice that it doesn't wait for the script to finish to output the data. So, i believe you can echo things to the browser at strategic points and then use flush(). I am using sleep() to simulate a long script here.
  20. Err, well i dont quite know why it would echo an 'M' But you are saying that $row = something or other, inside of quotes, which wont work, so this: $row = 'mysql_fetch_assoc($result_1)'; should be: $row =mysql_fetch_assoc($result_1); Oh, and drop the rubbish about protecting your secret project. If you want help you have to be willing to tell people what you are trying to achieve and give all the information.
  21. With all due respect, if you do seriously want to learn a language, then there will be times that you are going to have to try and figure something out for yourself. If you never do anything this, then i dont believe you will have actually learnt anything; is it not when trying to do something by yourself that you find out if you have learnt it or not? To be honest, i would recommend just starting using tutorials from the internet, including those on this site. They are free, and you can find out if you do really want to learn php before buying a book. I bought PHP and Mysql Web Development by Luke Welling and Laura Thompson probably 4-5months after having started learning PHP from internet tutorials. It is a very good book although i think it helps that i did already know a decent bit of php. I tend to use it both as a general refernece book, or to learn more about things which i dont really understand.
  22. Err, why is ths a problem? If someone has access to your database then you should be worried. Perhaps ive misunderstood.
  23. I think you need to use cURL for this. Just dont ask me how to use it :p
  24. Well that i dont understand. With your original code i get an error on line 25. I cant figure out what could possibly cause an error in creating that array, whatever your ini settings are. I am also using windows XP anyway. The only thing i can think is that perhaps in the code in your editor, there is a character that is not showing perhaps. Try copying the original code you pasted back into notepad and save it as a php file. Then try it again.
×
×
  • 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.