Jump to content

The Praetorian

Members
  • Posts

    333
  • Joined

  • Last visited

Everything posted by The Praetorian

  1. <?php$db = mysql_connect("localhost", "****", "****");mysql_select_db("localhost",$db);$search_string = $_GET['s'];$result = mysql_query ("SELECT * FROM dictionary WHERE word LIKE '%$search_string%' AND category != '' AND pronounce != '' AND definition != '' AND related != '' ORDER BY word ASC") or die(mysql_error());while ($r = mysql_fetch_array($result)){ foreach ($r as $val) { if ($val == "") continue 2; } $word = '<h2>'.$r['word'].'</h2><br />'; $category = '<span class="blue">Category:</span> '.$r['category'].'<br />'; $pronounce = '<span class="blue">Pronunciation:</span> '.$r['pronounce'].'<br />'; $definition = '<span class="blue">Definition:</span> '.$r['definition'].'<br />'; $related = '<span class="blue">Related Entries:</span> '.$r['related'].'<br />'; echo $word . $category . $pronounce . $definition . $related;?>
  2. Okay. I tried the different sql query. That didn't work. It only produced the latter half (s's on) of the entries. Even entering exact words didn't bring out the earlier entries. On the other hand, it did do what I was looking for. (Making the sections without anything in them invisible.)The second code didn't work at all. Gave me a parse error."Parse error: parse error, unexpected $end in C:\Program Files\xampp\htdocs\dictionary.php on line 99" Line 99 is my </html>..
  3. Okay. So that fixed that. Back to the main reason I wanted all the extra stuff though. heh. How can I make it so that, if one of the fields ([word][definition] and so on) is blank, the html won't show up? Because as of now the html is still showing up even though there's nothing in those fields.Or would it make it easier if I made it so that, when it queries the db, if there's a certain entry ("blank" or whatever) it won't output that particular field and its associated html?
  4. Okay. Now I'm getting some different results. Before, when I hit search with nothing in the search field, all the entries in the table would output in alphabetical order. Now, hitting search only outputs the very last item in the table. Before, if I hit search with just a single letter (a, b and so on) all the entries that start with that letter would output. Not now. In fact, if I just enter a single letter, again only the last entry outputs.
  5. Hm. Something about that has to be wrong. I added the code, but it's giving me a parse error. "Unexpected t_string". Here's the code as I edited it. <?php$db = mysql_connect("localhost", "username", "password");mysql_select_db("localhost",$db);$search_string = $_GET['s'];$result = mysql_query ("SELECT * FROM dictionary WHERE word LIKE '%$search_string%' ORDER BY word ASC") or die(mysql_error());while ($r = mysql_fetch_array($result))if ( !empty($r)){ $word = '<h2>'.$r['word'].'</h2><br />'; $category = '<span class='blue'>Class:</span> '.$r['category'].'<br />'; $pronounce = '<span class='blue'>Pronunciation:</span> '.$['pronounce'].'<br />'; $definition = '<span class='blue'>Definition:</span> '.$['definition'].'<br />'; $related = '<span class='blue'>Related Entries:</span> '.$['related'].'<br />'; }echo "{$r[word]$r[class]$r[pronounce]$r[definition]$r[related]";}?>
  6. Okay, I think I understand that well enough. Question though. Does that if statement need an else before the echo?
  7. Hm. Right. First things first. Code. <?php$db = mysql_connect("dbname", "username", "password");mysql_select_db("localhost",$db);$search_string = $_GET['s'];$result = mysql_query ("SELECT * FROM dictionary WHERE word LIKE '%$search_string%' ORDER BY word ASC") or die(mysql_error());while ($r = mysql_fetch_array($result)){echo "<h2>$r[word]</h2><br /><span class='blue'>Class:</span> $r[class]<br /><span class='blue'>Pronunciation:</span> $r[pronounce]<br />$r[definition]<br /><span class='blue'>Related Entries:</span> $r[related]";}?> As far as security is concerned it's not that much of an issue for this project. I'm only using this code for a dictionary type application for an rpg, and I keep the stuff backed up all the time. But yea. I'd prefer to do it with an if statement if I could, that would output the desired html if the field had something in it and nothing if not.
  8. Right. So I'm using this php/sql script for a dictionary/search engine. I'm doing all the tables from mysql. Here's what it looks like now. Search EngineAs you can see, I've inserted html for each of the fields that I've created on phpmyadmin. What I want to do (or at least find out if it's possible) is insert some more php to make it so that, if the field is blank, the html associated with that field won't appear.Again, not sure if that's possible. Or I may need to use javascript.Other question. Can I even use html in the actual sql script that makes up the entry? (The stuff that appears when $s[item] is processed into a block of text/int/varchar.) Right now I'm just inserting the html in between and around the $s[item] stuff, but it would be much easier if I could insert it straight in when I'm putting the information into that table.Thanks ahead of time for any help. Let me know if you need to see the php I'm using.
  9. That still doesn't explain why the cgi script would work on my live server but not on my localhost.
  10. Hm. Most of that made sense to me, but the code example I didn't understand at all. I've only been reading up on php and sql for a day or so.. so.. heh.I'm pretty sure the path to the cgi file is universal though. Lemme paste it for you.<!--#exec cgi="/cgi-bin/metablaster/metablast.cgi" -->So as you can see it should work, so long as there's a cgi-bin in my root folder. But adding one didn't do anything.As for cgi, the program that I download to make a server says that cgi is supported.
  11. I'm not actually expecting anyone to tell me exactly how to do this, since it's probably complicated. I was just hoping someone could point me in the right direction, or at least tell me if it's possible. Although, from my understanding of php and sql so far, it should be.I want to create a search-able dictionary. Where the person would enter a word or string of words into a text box and the code would then search the database I point it at to find the definition. The main thing I want though is for the code to only search the db I point it at, not the whole website. Since I want it to either pull up the appropriate definition or return a message like "that entry doesn't exist, please check to make sure you spelled it correctly" and so on.Once again, not expecting someone to code this for me (although I would kiss the feet of anyone who did). Just looking for some general info on where to look, what to focus on.Thanks.
  12. Right. So I have a remote server all set up on my computer. I'm using xampp, which has Apache and Mysql all rolled into one program.And I'm not really sure where to go now. I've been having a lot of really random problems. The tutorials I've been looking at have just done more to confuse me than anything.First.The structure of my local server seems to be different from my web server (the one I pay for). On there, it's root/public_html/(all my html files, pictures, css files and so on.) Public_html is technically the root, in the sense that it's where I put my index file.Within that directory there's a directory called cgi-bin, and that's where I put the cgi script that does my meta tags. Works fine on my web server.However, when I try to get it to work on my local server, nothing happens. On my local server, the structure is different. The cgi-bin is one level above my root folder. I tried creating a folder called cgi-bin in my root folder and transferring the files over, but that still didn't do the trick. Now, the path for the cgi script, the part that goes into the head of each of my html files that's effected, says root/cgi-bin/(program folder)/program.cgi. Going to that link should let me access the program. Instead, it gives me an error where that script appears on my pages. Nothing else is effected.I'm completely baffled by this, since I assumed the local server would run cgi scripts... am I mistaken?The other problem that I've been having is that all the tutorials I see keep telling me I need to use a dos window for my sql stuff. (Setting up tables, etc). But there doesn't seem to be any way to access the dos window... The server I got came with mysql which has a control panel for creating tables and databases, but none of the tutorials tell me how to use it. They all just tell me what to do in dos....
  13. Yep. That works fine. Here's another question though. Is there a conditional code for screen resolution?
  14. Okay, that one works, except that in IE the <![/end if]--> appears at the top of the page.
  15. On a side note, that conditional comment effected how my page looked on FF... not just IE.
  16. Okay, adding the conditional statement creates the weird effect of making a second vertical scroll bar within the browser window. Changing it so that the conditional statement effects the table width does nothing at all.This is part of the thing that's been annoying me. Shouldn't the image resize to fit the table width when I change it? It does in all the other browsers, but in IE the image seems to want to push the edges of the table out past the edge of the browser...EDIT:Okay. Once again, IE apparently ignores percents. When I use the conditional statement to make the width of the image a px number, it responds. Anyone know if the conditional statement will work in a .css file? Or if it only works in an html?
  17. I asked this a while ago, but no one seemed to have any answers. So I'll give it another shot.Take a look at my website ( http://www.tsrealms.com ) in IE on 800x600. Then look at in any other browser. Why is it that only IE refuses to fit? All the other browsers show it fine with the width I have on that table, but IE won't...Any ideas?
  18. Hm. Well, looking at the source code for that page, you have <html> twice... which may or may not be causing a problem. You only need that tag once per html page.I'm sure someone else will come along with a better explanation of doctypes.
  19. So here's another question. I was flipping through a book on html, xhtml, and css, and it mentioned something about adding an xmlns to the html tag. ( IE.. < html xmlns="something I can't remember, but something similar to a doc type" lang="en" > )Anyone know anything about that?
  20. Hm. Well, I tried adding it to my website, and the only difference I saw was that my banner image (which is two images one above the other) had a horizontal gap in it, whereas with 1.0 it didn't... So I guess I'll just stick with 1.0.
  21. Okay, here's a question. I followed the link from that page to the list of valid dtd's.What's the difference between xhtml 1.0 and xhtml 1.1?
  22. Yea. No idea why though. Doesn't seem to be your code...I do notice that the link with the # target doesn't have a file type. The link above it does (.htm) but the one that's not working has no file type extension. Which it should. But the wikipedia page it points to doesn't have one either, so that may be Wiki-pedia's error, not yours. The link above it works fine, so I don't think it's your code.If changing the ' to " doesn't work, I would say that it's something to do with the link itself.EDITOkay, after putting the link on my website exactly the way you have it, it worked fine the way it's supposed to... So I really don't understand why it isn't working from your website.
  23. Back to the pros and Cons...My girlfriend has a Mac, which, after having it for a few years still runs better than my brand new pc. Not as fast, but alot more stable and without all the glitches.Also, in all honesty, with Apple you get awesome customer service, where as Dell's customer service is awful. Like AOL, alot of their call centers are in other countries, so when you call you're getting someone in India who barely speaks english and is reading from a script and could probably care less about your computer problems. (This is from personal experience, by the way. With both Dell and AOL.)My girlfriend is always telling me how awesome the tech support people at Apple are. With Mac, you can take your Apple into any Mac store in the country and make an appointment to get it fixed there.I plan to buy both, however. In all honesty, Mac can't compete with PC's for gaming. Not yet at any rate. PC's are just way more powerful than Mac's are right now. Which may change before the next time I buy a computer, but for now, I plan to get a PC for games and a MAC for the internet.
  24. I don't know if this will matter, but I notice a few things about your code.1. In your <a> you have <a href='link'> That should be " not '.2. In that same block you have an open <p> tag without a </p>.
  25. I've actually started using conTEXT instead of Notepad2. It's somewhat slower on load time, but I prefer it's added features. Among them, tabbed browsing, and the ability to find/replace on all open files. Which really helps for editing multi-page menus.
×
×
  • Create New...