Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. www.ajaxfreaks.com Try the tutorials on there. They are very good.
  2. What is the exact error? I can see one problem: $image = "<a href=\"test.php\"><img src=\"images/standards/[b]\"[/b]{$row[lam_number]}-{$row[lam_name]}_40.gif\" alt=\"{$row[1am_name]}\" /></a>"; The bit in bold closes the src attribute but it looks to be like the following part should be apart of it.
  3. Can we have a bit more info? What happens when you run this script? And what is $var ?
  4. I cant actually see any part of the script which writes to a file...perhaps im just blind.
  5. So you want to populate a first drop down box from a database, then when the user selects from the first drop down box, populate the second and so on? If so, ajax is your friend here. Take a look at the tutorials over at www.ajaxfreaks.com
  6. All you have to do is make sure you store the member that created the post along with the post contents/title/date etc. Then, when you display the post, check to see if the current user is the same as the user who created the post. If it is then show them links to delete or edit the post. I hope that is what you were asking.
  7. Oh yeah, i forgot that fwrite would create the file if it didn't exist. I would think that is a better solution because you can write to it at the same time.
  8. [quote author=Barand link=topic=104530.msg417065#msg417065 date=1155765040] [quote author=BadGoat link=topic=104530.msg416989#msg416989 date=1155757051] Yep, changing the data type from date to text fixed it. :) Many thanks! [/quote] Bad choice. You should've gone with otuatail's solution. [/quote] Yes, this is because you will run into troubles if/when you need to perform things such as sorting on the date.
  9. Of course i dont mind... Basically, i switched the order of the code around. Previously, it would echo the table cell with the link to the kanji in first, then check to see if a new row was needed, if so it would end the current row and create the new one. If you imagine the last kanji in a lesson, it would have already echoed the cell with the kanji in BEFORE it created the new row, resulting in the first kanji of a new lesson being on the previous row. I have swapped it around so that it checks if a new row is requried and then echoes the the table cell containing the kanji. Hope thats clear, if not just say :p
  10. So you know how to write to files already? Well then all you should need to know is how to create them: http://uk2.php.net/touch
  11. Thats a sample line from inside the text file? :| Ok, well lets see the part that writes to the text file.
  12. Oh, a) Stop wining, if you want people to do something for you, there is a freelance forum. And b) Help us help you! Post a couple of the lines of sample info from the text file.
  13. store the last page in a variable then when you echo out the page number make sure its no more than 10 less than the last page.
  14. Ah, i know, its just the order its done. It checks to see if it should start a new row after it echos the cell... [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)){ if ($row[lesson] != $prevlesson && $prevlesson != ''){//make sure prevlesson has some contentes while ($x <= 15) { echo "<td>&nbsp;</td>"; $x++; } $x = 1; echo ' </tr> <tr>';                           echo '<td align="center"><a href="explain.php?kanji_id=' . $row[kanji_id] . '">' . $row[kanji] . '</a></td>'; } else {                         echo '<td align="center"><a href="explain.php?kanji_id=' . $row[kanji_id] . '">' . $row[kanji] . '</a></td>'; $x++; } $prevlesson = $row[lesson]; } echo " </tr> </table>"; ?> [/code] Try that
  15. $var = getCorporateProfile(); So the result of your query will be stored in $var;
  16. http://uk2.php.net/manual/en/function.mysql-list-tables.php
  17. Also, if you are echoing all html, e.g. no variables, then it is better to enclose the echo in single quotes: echo 'html goes here but no variables'; This is because PHP does not attempt to parse any contents inside of the singe quotes and is therefore quicker.
  18. [code] <?php $total_hours = 0;//assign 0 to it otherwise php5 will give a warning while ($RESULT = mssql_fetch_assoc($RESULTDS))  { echo "<tr align=center>"; echo "<td>"; //echo $combineddate; echo $RESULT['Lmo'];  echo "/"; echo $RESULT['Lda']; echo "/"; echo $RESULT['LYR']; echo "</td>"; echo "<td>"; echo $RESULT['Leave Code']; echo "</td>"; echo "<td>"; $total_hours = $total_hours + $RESULT['Hours']; echo $RESULT['Hours'];  echo "</td>"; echo "</tr>"; } //printf ("%01.2f", $TotalHours); print("</table>"); echo "Total hours: $total_hours"; ?> [/code]
  19. Here: http://www.ajaxfreaks.com/tutorials/2/0.php
  20. You've just got to swap it around like i did before... [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) { print "</tr><tr>"; $cc = 1; } else { $cc++; } } print "</tr></table>"; ?> [/code]
  21. Ah yes shoz, i fogot to change them on my post too. Also, it would make the script run quicker to add a break; in if a bad word is found because it only needs to know if one of the words is found: [code] <?php $sentence="hi there i think your a word1"; $words=array("word1","word2","word3","word4"); foreach($words AS $bad){ if(strpos($sentence,$bad)){ $badword = 'yes'; break;//break out of the loop if a bad word is found...continuing is unnecessary } } if($badword =='yes'){ echo " sorry but your useing bad words please try agin but be nice!"; exit; }else{ echo" your words are lovly"; exit; } ?> [/code]
  22. The problem with your way is that it would always exit the loop on the first iteration. If the first word in your array was in the sentence, it would have shown up as being a bad string, but because the first word in the array wasn't in the sentence, it was saying that the sentence was ok and then exiting. The way i did it, it loops through all of the words and if any of them are in the sentence it simply makes the variable $badwords equal yes. Then after the loop has finished it checks to see if the $badwords does equal yes, and if so it must mean that one of the bad words was found.
  23. [code] <?php $sentence="hi there i think your a word1"; $words=array("word1","word2","word3","word4"); foreach($words AS $bad){ if(strpos($sentence,$bad)){ $badword = 'yes'; } } if($badword =='yes'){ echo " sorry but your useing bad words please try agin but be nice!"; exit; }else{ echo" your words are lovly"; exit; } ?> [/code] Using strpos because it is the fastest way according to the manual.
  24. Leave the or die statement on the end of the query, it means you can always see whats going on. Two things, firstly, if you leave out the single quotes around the session variable then you dont need to use the .s e.g: $query = mysql_query("SELECT * FROM messages WHERE to = '$_SESSION[username]' AND read = 'no'") or die(mysql_error(); And second, i realise that you need to use the session to get this working properly, i was merely suggesting that you try a sample query in phpMyAdmin to establish wether or not it is a problem with the table, the query or your php code.
  25. Me neither. Umm, try doing the same query in phpMyAdmin, but obviously replace ".$_SESSION['username']." with llamaherder728
×
×
  • 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.