Jump to content
Larry Ullman's Book Forums

margaux

Members
  • Posts

    453
  • Joined

  • Last visited

  • Days Won

    52

Everything posted by margaux

  1. Could you be more precise about what the problem is? What are you expecting to happen and what is actually occurring? Are you getting any system error messages? Have you tried running your sql statements directly using something like phpmyadmin to determine if the queries are valid? I did notice that this statement mysqli_stmt_bind_param($stmt, 'sssssii', $addr1, $addr2, $city, $state, $zip, $c, $coun); refers to $c variable. Have you declared that variable? $q = "SELECT country_id, short_name FROM country"; $r = mysqli_query ($dbc, $q); if (mysqli_num_rows($r)> 0) { while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) { echo "<option value=\"$row[0]\""; //Check for stickyness if (isset($_POST['country'])&&($_POST['country']== $row[0])) echo 'selected="selected"'; echo ">$row[1]</option>\n"; } }else{ echo '<option>Please select a country.</option>'; } Is the above code the bit you don't understand? I haven't looked at it closely but basically it is getting all the countries from the d/b, looping through the results to display a drop down menu for the user to select a country and making the user's selection sticky. Look at the resulting source code to see how efficiently it creates the drop down menu for you. Hope that helps. Oh and could you use code tags for posting any code, it's the <> icon on the edit toolbar.
  2. Glad I could provide a little help. When I'm struggling with some code, I use var_dump and print_r to see what is being returned. Then I know how to manipulate the data.
  3. You're close. You have not stored your result anywhere with mysqli_fetch_array, so you won't be able to access the returned data. $table_name = "collection"; $column_name = "PENDING"; echo "<select name=\"$column_name\"><option>Select one</option>"; $q = "SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$table_name' AND COLUMN_NAME = '$column_name'"; $r = mysqli_query($dbc, $q); $row = mysqli_fetch_array($r); $enumList = explode(",", str_replace("'", "", substr($row['COLUMN_TYPE'], 5, (strlen($row['COLUMN_TYPE'])-6)))); foreach($enumList as $value) echo "<option value=\"$value\">$value</option>"; echo "</select>";
  4. Session_Start; session_start is a function so you need the brackets. I'm not sure if it needs to be in all lower case, but it is better practice. session_start();
  5. Your session_start needs to be the very first thing in strings.php and it needs to be between php tags. Assuming login.php creates $_SESSION['user_id'] and redirects the user to strings.php, try changing strings.php to start with <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...ransitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:la"en" lang="en">
  6. I agree with HartleySan. The code looks okay. Check the sql statement on its own. As written, the first time you run the above script, your error message will be displayed ("the description could not be added") so you might want to wrap it in an if statement that checks the form has been submitted.
  7. What about $q = "SELECT COSID,LastName,FirstName,CourseTitle,TeaLastName, TeacherID, GradeEarned FROM TranscriptView WHERE TeacherID = $_SESSION['user_id']";
  8. php is very helpful in that it provides error messages that indicate what the error is and where to look. Please look again at this statement and I'm sure you'll spot what the mistake is. The clue is in the NUMBER of bind parameters. mysqli_stmt_bind_param($stmt, 'idddddss', $a, $pn, $p, $s, $d, $i); For future reference, you don't need to post the whole script, just the relevant statements. Also please use code tags when posting code, it makes it easier to read.
  9. Hi ppvanya It would help us to help you if you were more specific about what the problem is. Specifically, what do you mean when you say the validation section isn't working and you can't validate the radio button group? Are you getting any errors? How do you know it isn't working? what are you expecting to happen? You will want to do some initial debugging - are you sure your query is running ok? You've set up 2 separate forms - is that what you meant to do? You should be able to use mysqli functions with xampp, and you should consider switching to mysqli because you are using deprecated functions which will not be supported for much longer. You might as well learn something that is going to last awhile. mysqli is very similar to mysql, look up the functions in the php manual, most of them are very similar with just a change in how the parameters are coded.
  10. use var_dump on the variables to ensure both are of type integer. You may need to typecast one or both of them. int($_SESSION['cart'][$row['sw_id']])
  11. For each category that you don't check at least one checkbox you will get the above warning because you have not understood how the global array $_POST works. $_POST is an array that gets created by submitting a form with a method of post. Its keys are the names of each input field in the form. The input elements only get inserted into the $_POST array if there is any data in them. So if you don't check a checkbox in the SP selection, $_POST['sp'] will not exist. In your form processing you need to first check if it exists before you do the foreach. If it doesn't exist the foreach statement will be skipped and you won't get the error. if (isset($_POST['sp'])) { foreach ($_POST['sp'] as $v) { $bodysp= 'SP selection: ' . $sp[$v]; } } if (isset($_POST['nd'])) { foreach ($_POST['nd'] as $v) { $bodynd= 'ND selection: ' . $nd[$v]; } } if (isset($_POST['dj'])) { foreach ($_POST['dj'] as $v) { $bodydj= 'DJ selection: ' . $dj[$v]; } } $bodysp is a variable and as such you can name it anything you want but it should meet the standard naming convention - start with a letter or underscore, followed by any number of letters, numbers, or underscores.
  12. You can start by looking in the php manual. You can use the procedural or the object oriented functions. Basically every mysql function you've used can be replaced by mysqli e.g. for mysql_query use mysqli_query. The main differences are the parameters each takes so you'll need to confirm what parameters are required and in what order.
  13. Hi I cut and pasted your code and ran it on my localhost and it worked fine. What's your host set up? Incidentally, the functions you're using are outdated. Look up the the mysqli extensions for interacting with the database. They are very similar to the mysql functions you're using but you'll be learning something that is current. Also you want to separate the styling from the html - but perhaps that is your next project.
  14. The site I referred to takes the following approach: 1. blog.php - handles displaying the blog. If the user clicks on the blog nav item, the user is shown excerpts from the last 5 posts each with a 'read more' link to the full article. This link links to blog.php with the title and id of the blog post e.g. blog/blog-post-title/7. This is the clean url. The mod_rewrite rule RewriteRule ^blog/([A-Za-z0-9\+\-]+)/([0-9]+)$ blog.php?t=$1&id=$2 says match anything that starts with 'blog' followed by a slash followed by any number of letters, numbers and dashes followed by another slash, followed by numbers and translate it to blog.php?t=$1&id=$2 where $1 is a variable and is equal to the first block and $2 is a variable equal to the second block e.g. blog.php?t=blog-post-title&id=7. In blog.php the title and id are accessed via the $_GET global. I've passed the title in the url as it is being used as the <title> tag in the HTML page in step 2. 2. if the user clicks on the 'read more' link, he is taken to a page that displays the one post in full. The t variable in the url is used as the title of the html page and as the heading. PHP is an evolving language so often a new function or class will be an improvement on an earlier function. For example the mysqli functions are an improved extension of the mysql functions. It's all a learning process and you will continue to pick up new ways of doing things. You will be surprised how quickly you will get to the point of being able to create the site you want as along as you keep at it. Like HartleySan said, feel free to ask any questions.
  15. You are correct in that some of the echo statements could be combined - in this case it comes down to the developer's preference as it won't impact on performance. As you know there are several ways the echo statement can be coded. I like the HEREDOC approach when echoing out lots of HTML but going by comments on some other forums I am definitely in a minority
  16. mod_rewrites are also covered in the Effortless Ecommerce book. For some reason, it took me awhile to master writing clean urls but I have managed it on my site. Have a look and see if that is what you require. Here's the code from my .htaccess file <IfModule mod_rewrite.c> RewriteEngine on #RewriteBase / RewriteRule ^archive/([A-Za-z0-9-]+)/?$ archive.php?a=$1 RewriteRule ^blog/([A-Za-z0-9\+\-]+)/([0-9]+)$ blog.php?t=$1&id=$2 RewriteRule ^blog/$ blog.php ErrorDocument 404 /404.php </IfModule> Be sure you update the links as well or they won't work.
  17. I had the same experience today and abandoned my search. Maybe they're doing some maintenance? or they've been hacked?
  18. This thread is about using CONVERT_TZ to display times in the user's geographic region. Have a look and let us know if it helped.
  19. I've been to a few meetups and its as HartleySan says - they all vary depending on the subject and the organiser. Here are some of my experiences: One called Untangle the Web usually has 3 different talks given by people established in the industry. I've only been to this one once and the the speakers were from digital agencies and their talks were well presented and informative. Another one I went to recently (can't remember the name of it) also had three presenters. One talk was given by a 20 year old who was clearly quite good at front end web design but not at public speaking. The 3rd talk was given by Rachel Andrew who has written several books on CSS and gave a very good talk on some of the new features in css3. It was great to get to speak with her afterwards. There is a huge php meetup once a month but it tends to give talks on on more enterprise related concepts and tecniques. My favourite is one often held in a Mozilla office and aside from providing beer, pizza, soft drinks, nice crisps and chocolate, is really good for meeting other coders to learn from and collaborate with. In summary, they are all different and you just have to try them out. I'm in Amsterdam at the moment and am thinking of going to one of Appsterdam's talks.
  20. Is it ok if I look at your site? www.margonline.co.uk Am away at the moment and posting from my phone, so apologies for the poor formatting.
  21. I have a portfolio section on my website to show my work which includes a link to the site and a summary of my role and skills used. Prospective clients can visit my site to view examples of my work.
  22. I've been freelancing for a over a year after spending a year learning web dev languages (I was working part time). I feel semi-confident with html, css, php and mysql. My learning mainly consisted of reading books, doing on-line tutorials and hanging out on a few forums. Answering questions on forums is a great way to learn - it will confirm your understanding (or not) of a particular concept, technique or function. You will also see alternative ways of doing things and learn new concepts, techniques and functions in the process. I've learned loads from this forum and a couple of others. One caveat with forums - be sure to familiarise yourself with the specific guidelines a forum follows because if you breach them, some come down heavy on you. Its really just a question of good manners, which can be forgotten when you're feeling frustrated that your programme won't work. I did attend one class which was okay - the upside of the class was mixing with people who had the same interest in learning web dev languages, the downside (besides the cost) was that we learned at different speeds. Search online for meetups in your area and attend them. I've been to a few and have met a number of people with whom I am able to collaborate and share ideas, experiences, resources etc. I was very reluctant to apply for and take on jobs as I didn't think I would be able to do them. I started with non-profits and sites for friends and explained that it was a learning experience for me and hopefully they would get a decent website. No question, the best way to learn and build your confidence is to jump in and do it. Then I started doing small jobs for agencies - you have to put in the time to find jobs and market yourself. Everyone wants to SEE examples of your work so build a portfolio online - use the non-profit jobs to start your portfolio and build a few 'example' sites if you have nothing initially. Add to your portfolio with each job. The first thing I do after handing over a site to a client is to update my portfolio. Recognise that you can't do everything - find people who have the skills you lack. Consider using university students who also need to build up a portfolio or crowdsourcing sites. Be realistic - its a slow process. And you'll always have crises of confidence. There's always more to learn but there are always resources to help you learn. Sometimes you just have to look really hard to find them. I hope some of this is useful.
  23. I've been freelancing for a over a year after spending a year learning web dev languages (I was working part time). I feel semi-confident with html, css, php and mysql. My learning mainly consisted of reading books, doing on-line tutorials and hanging out on a few forums. Answering questions on forums is a great way to learn - it will confirm your understanding (or not) of a particular concept, technique or function. You will also see alternative ways of doing things and learn new concepts, techniques and functions in the process. I've learned loads from this forum and a couple of others. One caveat with forums - be sure to familiarise yourself with the specific guidelines a forum follows because if you breach them, some come down heavy on you. Its really just a question of good manners, which can be forgotten when you're feeling frustrated that your programme won't work. I did attend one class which was okay - the upside of the class was mixing with people who had the same interest in learning web dev languages, the downside (besides the cost) was that we learned at different speeds. Search online for meetups in your area and attend them. I've been to a few and have met a number of people with whom I am able to collaborate and share ideas, experiences, resources etc. I was very reluctant to apply for and take on jobs as I didn't think I would be able to do them. I started with non-profits and sites for friends and explained that it was a learning experience for me and hopefully they would get a decent website. No question, the best way to learn and build your confidence is to jump in and do it. Then I started doing small jobs for agencies - you have to put in the time to find jobs and market yourself. Everyone wants to SEE examples of your work so build a portfolio online - use the non-profit jobs to start your portfolio and build a few 'example' sites if you have nothing initially. Add to your portfolio with each job. The first thing I do after handing over a site to a client is to update my portfolio. Recognise that you can't do everything - find people who have the skills you lack. Consider using university students who also need to build up a portfolio or crowdsourcing sites. Be realistic - its a slow process. And you'll always have crises of confidence. There's always more to learn but there are always resources to help you learn. Sometimes you just have to look really hard to find them. I hope some of this is useful.
  24. This is embarrassing. The wrong css file was being picked up as a consequence of moving the files between local and staging directories. All good. Sorry for wasting your time!!! Hangs head in shame
  25. I've nearly finished on a form for someone and its working fine except for a couple of display errors. 1. Form validation errors are displayed in a span next to the corresponding form field, but the error messages are not picking up the css. When I tested using html only, the css styles were applied. Here is the html output <!DOCTYPE html> <html> <head> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <meta charset="utf-8"> <title>Circuit Quote - assembly only budget</title><link href="styles.css" rel="stylesheet" type ="text/css" /> </head> <body> <div class="formWrap"> <form action="#" method="post"> <p>Circuit Quantity<label for="circuit_qty"><input type="number" id="circuit_qty" name="circuit_qty"/></label> <span class="error">Please enter a quantity</span></p> <p>Number of Different Components per Circuit<label for="num_circuit_components"><input type="number" id="num_circuit_components" name="num_circuit_components"/></label> <span class="error">Please enter the number of different components per circuit.</span></p> <p>Email me my quote<label for="email"><input type="email" id="email" name="email" size="30" placeholder="Enter your email address here"/></label> <span class="error">Please enter a valid email address</span></p> <p><input type="submit" value="submit" class="button" /><input type="hidden" value="aob" name="form_name" /></p> </form> <p class="centre">Assembly only budget quotation</p> </div> </body> </html> and here is the php script <div class="formWrap"> <form action="#" method="post"> <p>Circuit Quantity<label for="circuit_qty"><input type="number" id="circuit_qty" name="circuit_qty"/></label> <?php if (isset($errors['circuit_qty'])) echo '<span class="error">' .$errors['circuit_qty'] . '</span>';?></p> <p>Email me my quote<label for="email"><input type="email" id="email" name="email" size="30" placeholder="Enter your email address here"/></label> <?php if (isset($errors['email'])) echo '<span class="error">' .$errors['email'] . '</span>';?></p> <p><input type="submit" value="submit" class="button" /><input type="hidden" value="aob" name="form_name" /></p> </form> and the css .formWrap {width:90%;margin:20px auto; background-color:#151b97; color:#d7d7d7; font-family:trebuchet, sans-serif;padding:10px; overflow:hidden;} .clear {clear:both; } input {border:1px solid yellow; background-color:#151b97;margin-left:15px; color:yellow; width:120px;} input[type=email]{width:300px;} .clearfix {clear:both;} #data_table {width:60%; margin:auto;} td {padding:2px 4px;} .button {color:#d7d7d7; border:1px solid #d7d7d7;} .centre {text-align:center;} .error { color:#d9a100; } I've run the html and the css through the W3C validators and no errors came up. So this is puzzling. 2. I'm using money_format() to display a table of prices and want the prices to align vertically in the columns so that all the commas and decimal points are aligned. I've looked up the function in the php manual and I"m not sure this function caters for what I want. Anyone know of an alternative?
×
×
  • Create New...