Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. try using htmlentities: <?php echo htmlentities($rest_name_old); ?> The problem is that you are using single quotes to contain the value for the text box. Therefore when HTML finds the next single quote (the one in the string you are echoing) it thinks that is the termination of the value of the text box.
  2. It appears to be fine to me, are you sure you are echoing $errorMessage? The only thing i'd do is make a slight change to your pattern: if(preg_match("/^http:\/\//", $link)) { This ensures that http:// is found at the start of the string, rather than anywhere in it.
  3. I would assume that this line: $members = $db->select($members); Is supposed to be: $members = $db->select($query);
  4. Anything that is between the /* and */ will be commented out - you don't need to worry, there is no code that is executed. Im not entirely sure why they have placed the @ sign in the comments; perhaps it was for the developers. As for why it appears coloured, ive never used that particular application so i cannot be sure, but i would guess that it highlights anything where you suppress errors. The @ symbol is used to ignore errors on a single line.
  5. Something like: <?php $query="SELECT name FROM admin where timecounter='1'"; /*order by clause to the sql statement if the names are to be displayed in alphabetical order */ $result = mysql_query ($query) or die(mysql_error()); echo "<select name='drop1'"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo '<option value='.$nt['id'].'>'.$nt['name'].'</option>'; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </p> <p> <input type="submit" name="Submit" value="Submit" > </p> </form> <?php if(isset($POST('Submit'))){ echo 'Name is: '.$_POST['drop1'].'<br />Product Description: '.$_POST['jobdescription']; } </body> </html> Edit: You do however realise that you will be getting the ID from the drop down box and not the name? Since you set the value of each option to the id rather than the name, that is what you will receive. This is probably what you want if you are doing anything with a database, but not if you want to display the name.
  6. GingerRobot

    Geese

    As neylitalo says, there are some general rules - but also many exceptions. Taking french: Most nouns ending in é,age, eau, ège and isme are male, whilst those ending in ée, tion, itude, ience and ité are female. There are hundreds of exceptions though. And as was touched upon, you cannot assume that any conotations of a word would be linked to its gender. To give my favourite example, the word feminism (which is the very similar féminisme) is actually a male word!
  7. I assume by "turn if off your end" they meant that you need to make your code compatible with the settting off. If they are hosting your website and have turned off the setting then there is nothing to "turn off". If you have no real interest in security, and really just want a fix to make the site work, then adding the following bit of code to the top of your scripts should sort it out for you: <?php extract($_POST); extract($_GET); extract($_SERVER); extract($_SESSION); extract($_COOKIE); ?> If you'd rather fix the code properly, i suggest you read up a little about the register_globals setting. Here would be a good place to start: http://uk.php.net/register_globals If you do intend to retrieve the variables from their respective superglobal arrays, e.g.: <?php $var = $_POST['var']; ?> Then it may be advantageous to add in this piece of code: error_reporting(E_ALL); To the top of your php files. This will make sure you receive notices for undefined variables - which is what all of the variables that are being used without being retrieved from their respective arrays will be. However, (and hence the underling of the may) it could be that the code was not written particularly well, and you'll run into other notices which may confuse the issue whilst not affecting the running of the script. I hope some of that helps.
  8. I found this one a while back: http://www.glpayment.co.uk/ No idea if they're any good.
  9. GingerRobot

    Geese

    As was pretty much pointed out earlier, ALL languages have their irregularities(perhaps with the exception of contructed languages such as Esperanto). Languages evolve with usage, hence why the most used parts of language tend to be the ones which least follow the rules. Taking french as an example, the most irregular verbs are the most common - avoir(to have), etre(to be), faire (to do) - whilst the majority of obscure verbs are regular. I dont think you notice this so much with your primary language; its far more noticeble when you have to make the effort to learn a new one(hence why i gave the example from french)
  10. I thought as much. Line 12 is your problem. Delete this one: $row_result = mysql_fetch_assoc($result); If you take a look at the manual (it probably explains it better than i can), you will see that by calling the mysql_fetch_assoc function, you move the internal pointer forward. This essentially means that each time you use the function, you work with the next row of data. In your code, you call this prior to your loop. Therefore, when the loop is executed, it starts work on the second row.
  11. Ok, its probably time we got an updated version of the code you are using. Othewise we might make suggestions on code that is no longer being used. Might be an idea to comment out any of your testing too - so we dont confuse the issue.
  12. With just a quick glance, i would guess your problem is actually with this piece of code: if(empty($page)){ $page = 1; } Unless you have register_globals turned on, $page will always be undefined. You need to retrieve it from the $_GET array. Replace the above code with: $page = (!isset($_GET['page'])) ? 1 : $_GET['page']; And give it a whirl.
  13. Well im not entirely sure what thats about. As far as i can see, there is only one closing bracket, which is the one which closes the mysql_query() function. The second one was indeed a typo on my part. As for the mysql error, i cant see why you should be getting one. Unless you're not using the code you posted, and you're using the pre-edited version of my code(when i first posted, i acidently wrote REGEXP twice). Try changing the query to: $sql = "SELECT * FROM documents WHERE doc_title ".$parameter; $result = mysql_query($sql) or die(mysql_error().'<br />Query:'.$sql); So we can see what the contents of the query is if there is an error.
  14. Question 1: The . is used as a separator between the table name and the field name. 'd' is being used an an alias for the documents table (documents AS d), whilst c is being used as an alias for the categories table. The query reads something along the lines of "Select all the fields from the table d, and all the fields from the table c...." As for your second question, i think you'll be wanting regular expressions. Id do something like: <?php if($_GET['alphaID'] == '0-9')){ $parameter = "REGEXP '^[0-9]'"; }else{ $parameter = "LIKE '{$_GET['alphaID']}%'"; } $result = mysql_query("SELECT d.*,c.* FROM documents AS d LEFT JOIN categories AS c ON d.cat_id=c.cat_id WHERE d.doc_title ".$parameter); ?> That way, we only use have the overhead of the regular expression when we need it, otherwise we use the orginal LIKE comparison. It's rather like you english description of the problem. Edit: Beaten to it, but thought id post anyway. Didn't want to waste the typing. Also shows an alternative to the IN clause.
  15. Well, a quick check of the source code tells me none of your PHP is being executed. This could be for a number of reasons. Hopefully it is just a case of the short_open_tags directive being set to off. Try using full opening tags (<?php) instead of short ones (<?).
  16. Add something else to your search parameters? $genre_query = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_inventory WHERE ".$glob['dbprefix']."CubeCart_inventory.customer_id=customer_id AND deleted = 0 AND customer_id="" AND cat_id=".$prodArray[0]['cat_id']." AND artist != '$current_artist' ORDER BY popularity DESC LIMIT 9"); Obviously, i don't know how you will get the current artist, since i don't know how your page is written. Ive just called the variable $current_artists. You'll need to change that.
  17. The correct syntax is: ALTER TABLE `tablename` CHANGE `fieldname` `newfieldname` FIELD TYPE DEFAULT 'Default value' For example, to set the default on an int field back to 0, you might do something like: ALTER TABLE `ratings` CHANGE `timestamp` `timestamp` INT( 50 ) NOT NULL DEFAULT '0' p.s. Please don't type in capitals. It's incredibly annoying.
  18. Something along the lines of: <?php if(isset($_POST['submitbutton1'])){ //process 1st form } if(isset($_POST['submitbutton2'])){ //process 2nd form } //any html headers/css etc ?> <form action=<?php echo $_SERVER['phpself'];?> method="POST"> <?php if(!isset($_POST['submitbutton2'])){ if(!isset($_POST['submitbutton1'])){//neither form submitted //show first form echo '<input type="submit" name="submitbutton1">'; }else{//first form has been submitted //show second form echo '<input type="submit" name="submitbutton2">'; } } ?>
  19. Sounds like you've not installed apacle mysql and php properly. If you want a quick an easy way, i suggest you uninstall whatever you have installed, and just download WAMP: http://www.wampserver.com/en/ Will install apache, php & mysql + phpmyadmin with one installation. Very easy.
  20. Ive only taken a quick look at your code, but i can certainly see an issue with the css. If the page is the active one, you give the link the class name 'selected'. Yet you don't appear to define this class in your css code.
  21. Sorry, yes its late. That wasn't ever really going to work. Given that you're including a file each time, it should be a simple matter of defining the title in each of these pages. You should only show the title for the index file if no page has been included: <?php if(!isset($_GET['page'])){ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Welcome to my website. This is the Index page</title> </head> <body> Some content </body> </html> <?php }else{ include('includes/'.$_GET['page'].'.php'); } ?> On a side note, if you are including files in this manner, you would be wise to validate the input from the $_GET array to make sure the page you are including is supposed to included.
  22. I would suggest the simplest method is to define a variable which is the name of page that is doing the including, which you set just before you include your navigation page. Something along the lines of: <?php $current_page = 'somepage.php'; include('includes/Nav.php'); //the rest of your code ?> Then, Nav.php: <?php $pages = array('link name for page 1'=>'page1.php','Name of The Link for Page'=>'somepage.php','Foo bar'=>'foobar.php');//using an array will make it simpler to add new pages print_r($pages); foreach($pages as $k => $v){ echo '<a href="'.$v.'" class="'; echo ($v=$current_page)? 'normal' : 'purple'; echo '">'.$k.'</a>'; } ?> You'd then define two classes for your links. I've called them normal and purple here. Notice how ive set the array up so the key is the title for the page(e.g. the text of the link), whilst the value is the actual page.
  23. Alternatively, you could define an array of possible pages: <?php $pages = array('page1','page2','page3');//array of possible pages; if(isset($_GET['pg']){ if(!in_array($_GET['pg'],$pages)){ header("location:error.php"); exit; }else{ //your nasty block of if statements here } } ?> A better solution would be a re-write so you dont have such a block of if-elseif statements.
  24. There's really no need to bump your post after half an hour. Anywho, you could do something along the lines of: <?php $page = $_GET['page'];//im assuming that the file you are including is being passed in the URL somehow. include('includes/'.$page.'.php');//again, no idea if this is how you are doing it - thats the trouble with no code being posted //use a switch statement: switch($page){ case 'page1': $title = 'Some title for page 1'; break; case 'page2': $title = 'A different title for page 2'; break; case 'page3': $title = 'Guess what? Another title'; break; default://if no page set - e.g. its just the index page $title = 'Welcome to my website'; break; } //further down your script echo '<title>'.$title.'</title>'; ?> Alternatively, you could define the $title variable within each page that you might include. You'd then set a title on the index page, which would be overridden if you do include a file. For example, index.php: <?php $title = 'Your default title'; $page = $_GET['page']; include('includes/'.$page.'.php'); //further down your script echo '<title>'.$title.'</title>'; ?> Then all of your files to be included: <?php $title = 'Your title for this page'; //the rest of your script ?>
×
×
  • 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.