Jump to content

AndyB

Member
  • Posts

    37
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

AndyB's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. AndyB

    Learning PHP

    On the "Kilersites University" course,Ben. Here's the url http://www.killersitesuniversity.com/users/courses/ Thanks Ben.
  2. AndyB

    Learning PHP

    Hello everyone, My name is Andrew and I've started Ben's "CRUD with PHP and MySQL" course("Hello Ben!") I am working on the "Updating Records" lesson now, but for some reason it appears that the "Creating New Records" and "Editing Existing Records" lessons are not available,i.e. when I hover over them, they do not highlight. I'd be grateful for tips on how to access those lessons? With thanks, Andrew.
  3. Hello Ben, Would it be possible at all to get a link to that post of yours from late 2010 in which you wrote down and commented on the code for the "Edit","Delete" and "Update" php pages for the" CRUD with PHP and MySQL"? I'm a bit concerned with making unnecessary errors when writing the code, I thought that if I have your work, I can self-correct if I get error messages. Many thanks in advance for your help Ben, With regards, Andrew.
  4. Hello Ben, I just wanted to thank you for your help with the username and password errors I was facing. It's only a little database but it's quite tricky when you do it from the Web Host. I had to figure out how to create the user name, password and database on the Web Host by myself, which was a lot of trial and error, though of course, it is quite trivial for an experienced programmer. I'm quite happy to start the "Prepared Statements in MySQL" video now. This is a link to my database, I've still got to write the code to edit and add records to it, but I think that comes up in videos 5 and 6. http://www.spintheclock.com/PHPWork/view.php Many thanks for your help Ben, With regards, Andrew.
  5. Hello Ben, Thanks a lot for the corrections you suggested and which I actually implemented with the help of a post from yesterday by another user. I think that the user went back to a post of yours with a thorough breakdown of all the pages for the CRUD/PHP/MySQL videos. I don't know if it was intentional but it was quite helpful, I tried to look her name up but there have been many posts since so I couldn't find her to say thanks. Anyway I used the code that you had written with the commented lines that explain clearly what each section does. I have unfortunately come up with some new error messages which I looked up on the Net because they seem to be quite generic. I think they're called mysqli "prepared statements". Warning: mysqli::mysqli() [mysqli.mysqli]: (42000/1044): Access denied for user 'spinthe3_andrewb'@'localhost' to database 'spinthe3_records2' in/home/spinthe3/public_html/PHPWork/connect-db.php on line 8 Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in /home/spinthe3/public_html/PHPWork/view.php on line 18 Warning: main() [function.main]: Couldn't fetch mysqli in /home/spinthe3/public_html/PHPWork/view.php on line 52 Error: Warning: mysqli::close() [mysqli.close]: Couldn't fetch mysqli in /home/spinthe3/public_html/PHPWork/view.php on line 56 Could it mean that my sql password might be invalid? It's strange because the error messages seem to all be related to a syntax error with "mysqli" somehow. WHy couldn't the server "fetch mysqli"? Many thanks in advance for your insight on this matter Ben, Regards, Andrew.
  6. Hello Ben, Thanks for your help with those faulty lines. I've made the necessary changes but now I get this error message: Parse error: syntax error, unexpected T_ELSE in /home/spinthe3/public_html/PHPWork/view.php on line 58 I don't know why that would come up,here's my updated code and thanks again for your help with this matter Ben. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>View Records</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <h1>View Records</h1> <?php include('connect-db.php'); if ($result = $mysqli->query("SELECT * FROM players ORDER BY id")); { if ($result->num_rows > 0) { echo "<table border='1' cellpadding='10'>"; echo "<tr><th>ID</th><th>First Name</th><th>Last Name</th><th></th><th></th></tr>"; while($row = $result->fetch_object()) { echo "<tr>"; echo "<td>" . $row->id . "</td>"; echo "<td>" . $row->firstname . "</td>"; echo "<td>" . $row->lastname . "</td>"; echo "<td><a href='records.php?id=" . $row->id . "'>Edit</a></td>"; echo "<td><a href='delete.php?id=" . $row->id . "'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; } else { echo "No results to display!"; } } else { echo "Error: " . $mysqli->error; } $mysqli->close(); ?> <a href="records.php">Add New Record</a> </body> </html>
  7. Hello Ben, I've been working on the "CRUD with PHP and my SQL" course for a couple of weeks now. The material is very interesting and I am really looking forward to building my first app. However,I'm having difficulty with displaying the view.php file in my browser, I must say that I use my web host for this purpose. This is the error message that I get: Parse error: syntax error, unexpected '>' in /home/spinthe3/public_html/PHPWork/view.php on line 35 I must have made an error with the code and would be grateful for your insight Ben. Many thansk in advance for your time, Regards, Andrew. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>View Records</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <h1>View Records</h1> <?php include('connect-db.php'); if ($result = $mysqli->query("SELECT * FROM players ORDER BY id")); { if ($result->num_rows > 0) { echo "<table border='1' cellpadding='10'>"; echo "<tr><th>ID</th><th>First Name</th><th>Last Name</th><th></th><th></th></tr>";" while($row = $result->fetch_object()) { echo "<tr>"; echo "<td>" . $row->id . "</td>"; echo "<td>" . $row->firstname . "</td>"; echo "<td>" . $row->lastname . "</td>"; echo "<td><a href='records.php?id=" . $row->id . "'>Edit</a>"</td>"; echo "<td><a href='delete.php?id=" . $row->id . "'>Delete</a>"</td>"; echo "</tr>"; } echo "</table>"; } else { echo "No results to display!"; } } else { echo "Error: " . $mysqli->error; } $mysqli->close(); ?> <a href="records.php">Add New Record</a> </body> </html>
  8. Hello Ben, I hope you had a good Christmas with friends and family. I've just completed the PHP tutorial on arrays now and I've had a crack at both "Indexed" and "Associative" arrays. This is the code from the tutorial on "Associative" arrays that I wrote as an exercise: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> 1st Associative Array</title> </head> <body> <?php // indexed array $my_array = array("Derivatives","PHP","JavaScript",40); print $my_array[2]; print "<br><br>"; $prices_array = array("iPad" => "1300.00", "MacBook" => "800.00", "iPhone" => "100.00", ); print $prices_array['iPad']; ?> </body> </html> The code did work alright,displaying "JavaScript" and "1300.00" in the browser. However,at first, I had added £ signs in the values such as "£1300.00" or "£800.00". I had also written the names as such:"i-Pad", "i-Phone"and code wouldn't work. My 1st query today is: 1) Was my initial name-value annotation incorrect? The tutorial also shows another way of displaying the array: $prices_array = array ("iPad" => "1300.00", "MacBook" => "800.00", "iPhone" => "100.00" ); print $prices_array['iPad']; My 2nd query is: 2) Is one way of building the array preferable to the other for reading convenience ? Many thanks in advance for your help with this query Ben, Regards, Andrew.
  9. Hello Ben, Thanks a lot for your reply to my e-mail from last Monday about the "include" keyword. I've just completed the tutorial on arrays now and I've had a crack at both "Indexed" and "Associative" arrays. This is the code from the tutorial on "Associative" arrays that I wrote as an exercise: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> 1st Associative Array</title> </head> <body> <?php // indexed array $my_array = array("Derivatives","PHP","JavaScript",40); print $my_array[2]; print "<br><br>"; $prices_array = array("iPad" => "1300.00", "MacBook" => "800.00", "iPhone" => "100.00", ); print $prices_array['iPad']; ?> </body> </html> The code did work alright,displaying "JavaScript" and "1300.00" in the browser. However,at first, I had added £ signs in the values such as "£1300.00" or "£800.00". I had also written the names as such:"i-Pad", "i-Phone"and code wouldn't work. My 1st query today is: 1) Was my initial name-value annotation incorrect? The tutorial also shows another way of displaying the array: $prices_array = array ("iPad" => "1300.00", "MacBook" => "800.00", "iPhone" => "100.00" ); print $prices_array['iPad']; My 2nd query is: 2) Is one way of building the array preferable to the other for reading convenience ? Many thanks in advance for your help with this query Ben, Regards, Andrew.
  10. Hello Ben, Thanks a lot for the link you sent me last week to illustrate the difference between the "echo " and "print" keywords". I've got a query about another keyword today which I was hoping you might be able to spare some time on. In the PHP basics 2 tutorial, there's a lesson on the "PHP includes" function. The video demonstrates how a footer can be added to a main page by using the "include " keyword. The tutorial says that the "include" keyword can be used with or without the"@" symbol: -@include or, -include My understanding of it is that: -if the"@" symbol is included and that it links to a non-existent file, no error message will display in the browser -if the "@" symbol is not included and that it links to a non-existent file, an error message will display in the browser. My query therefore is: 1) Is the"@" symbol used with the include function depending on whether or not we plan for the page to be displayed to viewers? Many thanks in advance for your help with this query Ben, With regards, Andrew.
  11. Hello Ben, Many thanks for your last e-mail and your sound advice about the Filezilla transfer. I followed your instructions and was lucky enough to get the desired result. This is the code I wrote for the 1st PHP page which is in video 7 of the PHP basics1 Folder : <!DOCTYPE HTML PUBLIC "-??W3C??DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>1st PHP</title> </head> <body> <?php print "Hello World."; ?> </body> </html> In the video it is recommended to use the "print" function as opposed to "echo",which I've come across before. 2) Is there any difference between the "print" and "echo" functions? Many thanks in advance for your help Ben, Regards, Andrew.
  12. Hello Ben, Thanks for your reply to my post last Thursday. I started the PHP course in the order that you suggested and I've almost completed the php.basics1 folder. I'm having though with something trivial though and I would be grateful for your insight on this matter. In the video, Stefan recommends testing your PHP scripts on: -Local servers such as WAMP or XAMPP -Web host servers. My Web server is Just Host so I decided to focus on this approach. However, the video seems to focus more on people using local servers. I haven't been able to pick up on instructions to test scripts on Web hosts servers. I have written the following basic code from the video: <!DOCTYPE HTML PUBLIC "-??W3C??DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>My 1st PHP</title> </head> <body> <?php print "Hello World."; ?> </body> </html> and saved it as a Notepad file with a PHP file extension. I've tried to upload it to the public_html folder of the Web host in a folder which I called PHP Work but without success. Could you please recommend a way to upload Notepad files to the Web host server to test the scripts? Many thanks in advance for your help Ben, Regards, Andrew.
  13. Hello Ben, I hope you're OK and that work is going alright for you too. I've just purchased the PHP for Beginners tutorial from the store. I realise that without at least a basic understanding of PHP, it's going to be difficult to communicate with real developers. I downloaded 4 zip files: -PHP basics 1 -PHP basics 2 -PHP misc -PHP object oriented programming I suspect that it might not make much of a difference but in which order would you recommend I study these topics? Would you have any general advice about a "best practice" method to use to get to grips with the material thoroughly? Many thanks in advance for your advice Ben, Regards, Andrew.
  14. Hello Ben, Thanks a lot for your reply to my last post. Honestly, your insight was flawless, it was all down to re-writing the code in the header.php template. We had my wife's cousins who are from East Stroudsberg,Pennsylvania visit us for Thanksgiving in the last couple of days. To make a long story short, one of them, Sidney, works in Web development. It was the strangest of coincidence but we ended up talking about design, a thing led to another and he decided to tinker away with the site code. It was very lucky for me because I struggle a lot with PHP with which I'm not fluent at all. Anyway,these are the changes he implemented on the basis of your code. So thanks again for your insight Ben. www.spintheclock.com <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head profile="http://gmpg.org/xfn/11"> <title><?php woo_title(); ?></title> <?php woo_meta(); ?> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" /> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php if ( get_option('woo_feed_url') <> "" ) { echo get_option('woo_feed_url'); } else { echo get_bloginfo_rss('rss2_url'); } ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <?php wp_head(); ?> <?php woo_head(); ?> </head> <body <?php body_class(); ?>> <?php global $woo_options; ?> <div id="background"> <div id="top"> <div class="col-full"> <?php if ( function_exists('has_nav_menu') && has_nav_menu('primary-menu') ) { wp_nav_menu( array( 'depth' => 3, 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_class' => 'nav1', 'theme_location' => 'primary-menu' ) ); } else { ?> <ul class="nav1"> <?php if ( get_option('woo_custom_nav_menu') == 'true' ) { if ( function_exists('woo_custom_navigation_output') ) woo_custom_navigation_output('name=Woo Menu 1&depth=3'); } else {/* ?> <li <?php if ( is_home() ) { ?> class="current_page_item" <?php } ?>><a href="<?php echo get_option('home'); ?>/"><?php _e('Home', 'woothemes'); ?></a></li> <?php wp_list_pages('sort_column=menu_order&title_li=&depth=3'); ?> <?php*/ } ?> </ul> <!--/nav1--> <?php } ?> <div class="subscribe"> <?php _e('Subscribe:', 'woothemes'); ?> <a class="posts" href="<?php if ( get_option('woo_feed_url') <> "" ) { echo get_option('woo_feed_url'); } else { echo get_bloginfo_rss('rss2_url'); } ?>"><?php _e('Posts', 'woothemes'); ?></a> <span class="sep">|</span> <a class="comments" href="<?php bloginfo('comments_rss2_url'); ?>"><?php _e('Comments', 'woothemes'); ?></a> <?php if (get_option('woo_subscribe_email') != "") { ?> <span class="sep">|</span> <a class="email" href="<?php echo get_option('woo_subscribe_email'); ?>" target="_blank"><?php _e('Email', 'woothemes'); ?></a> <?php } ?> </div> <div class="fix"></div> </div><!-- .col-full --> </div><!-- #top --> <div id="header"> <div class="col-full"> <div id="logo" > <?php if (get_option('woo_texttitle') <> "true") : $logo = get_option('woo_logo'); ?> <a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('description'); ?>"> <img class="logo" src="<?php if ($logo) echo $logo; else { bloginfo('template_directory'); ?>/images/logo.png<?php } ?>" alt="<?php bloginfo('name'); ?>" /> </a> <?php endif; ?> <?php if( is_singular() ) : ?> <span class="site-title"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></span> <?php else : ?> <h1 class="site-title"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1> <?php endif; ?> <span class="site-description"><?php bloginfo('description'); ?></span> </div><!-- #logo --> <?php if ( $woo_options['woo_ad_top'] == 'true' ) { ?> <div id="topad" class="fr"> <?php if ($woo_options['woo_ad_top_adsense'] <> "") { echo stripslashes($woo_options['woo_ad_top_adsense']); } else { ?> <a href="<?php echo $woo_options['woo_ad_top_url']; ?>"><img src="<?php echo $woo_options['woo_ad_top_image']; ?>" width="468" height="60" alt="advert" /></a> <?php } ?> </div><!-- /#topad --> <?php } elseif ( $woo_options['woo_disable_search'] != 'true') { ?> <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/"> <div id="search"> <input type="text" value="<?php _e('Enter search keyword', 'woothemes'); ?>" onclick="this.value='';" name="s" id="s" /> <input name="" type="image" src="<?php bloginfo('template_directory'); ?>/images/btn-search-trans.png" value="Go" class="btn" /> </div><!--/search --> </form><!-- #searchform --> <?php } ?> <div class="fix"></div> </div><!-- .col-full --> </div><!-- #header --> <div id="topmenu"> <div class="col-full"> <?php if ( function_exists('has_nav_menu') && has_nav_menu('secondary-menu') ) { wp_nav_menu( array( 'depth' => 6, 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_class' => '', 'menu_id' => 'nav', 'theme_location' => 'secondary-menu' ) ); } else { ?> <ul id="nav"> <?php if ( get_option('woo_custom_nav_menu') == 'true' ) { if ( function_exists('woo_custom_navigation_output') ) woo_custom_navigation_output('name=Woo Menu 2'); } else { ?> <?php //wp_list_categories('title_li=&exclude=') ?> <ul class="sf-menu"> <li><a href="<?php echo bloginfo('url'); ?>/" >Home</a></li> <li><a href="<?php echo bloginfo('url'); ?>/about" >About</a></li> <li><a href="<?php echo bloginfo('url'); ?>/stories-2" >Stories</a> <ul> <?php $mypages = get_pages('child_of=131&post_type=page&sort_order=asc'); //echo "<pre>"; print_r($mypages); die; foreach($mypages as $page) { ?> <li><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></li> <? } ?> </ul> </li> <li><a href="<?php echo bloginfo('url'); ?>/contactlinks" >Contact</a></li> <li><a href="<?php echo bloginfo('url'); ?>/comments" >Comment</a></li> </ul> <?php } ?> <li> </li> </ul> <?php } ?> <div id="rss" class="fr"> <a href="<?php if ( get_option('woo_feed_url') <> "" ) { echo get_option('woo_feed_url'); } else { echo get_bloginfo_rss('rss2_url'); } ?>"><img src="<?php bloginfo('template_directory'); ?>/images/ico-rss-trans.png" alt="RSS" /></a> </div><!--/rss --> </div><!-- .col-full --> </div><!-- #topmenu--> <div id="content" class="col-full">
  15. Hello Ben, For further clarification, this is the code that I had in my "Stories" tab,which was a page in "Editor" mode, prior to the template change. <?php global $post; $myposts = get_posts( 'offset=4&post_type=page&order=asc' ); ?> <ul> <?php foreach( $myposts as $post ) : setup_postdata($post); ?> <?php $url = substr_replace(get_permalink(), '#', strrpos(get_permalink(), '/')+1, 0); ?> <li><a href="<?php echo $url; ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> But now as you can see, when you click on the hyperlinks, they only invariably display the "Home" page. Also, the "Comments" and "Posts" links don't display the correct content. To sum it up: 1) How can I get the stories to display from the "Stories" tab only and not be on the top menu? 2) How can I remove the extra "Home" link? 3) How can I remove the "No Categories" tab? 4) How can I re-enable the "Posts" and "Comments" links? Your help would be greatly appreciated yet again Ben, With thanks, Andrew.
×
×
  • Create New...