Jump to content

guybrown

Members
  • Posts

    5
  • Joined

  • Last visited

guybrown's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Works great. Now I can spend the evening understanding $var = isset($_GET["test"]) ? $_GET["test"] : ''; Much appreciated!
  2. Hi all I am doing a video tutorial on GET but I get a 'notice' that the tutor doesn't: Notice: Undefined index: test in C:\xampp\htdocs\database\vartest2.php on line 2 Can I switch notifications like this off? Here is the php code: <?php $var = $_GET["test"]; $len = strlen($var); if ($len > 0) { echo $len; } else { echo "error: no input"; } ?> <form action="vartest2.php" method="GET"> <input type="text" name="test"> <input type="submit" value="Submit"> </form> This is what the tutor and I are entering into our browsers: http://localhost/database/vartest2.php (If I put ?test=anything at the end of the above, I don't get the notification but can't you just not specify ?test=... at the end?) Displayed in my browser: Notice: Undefined index: test in C:\xampp\htdocs\database\vartest2.php on line 2 error: no input Displayed on the tutor's browser: error: no input I'm using Google Chrome Version 27.0.1453.94 m Any help appreciated. Regards, Guy Brown
  3. Hi Motion125. I am also new to this forum. I am learning html, css, php and mysql at the moment and know very little but I'm enjoying it. I joined this forum tonight because I needed some help and within 10 minutes I received some help so I'm impressed already. Hopefully I will be able to provide support to people one day when I'm more experienced. Good luck! Regards, Guy.
  4. Much appreciated pbs! Thank you very much. The echoes that were there to help me identify any issues were causing the issues. Cheers, Guy.
  5. Hi all I'm new to programming and this forum and know very little about php. Any help would be greatly appreciated and I look forward to contributing and supporting others as my knowledge increases. I am trying to get a 'counter' php file working on my localhost. When I run the php file in chrome I get the following error: Parse error: syntax error, unexpected '$result' (T_VARIABLE), expecting ',' or ';' in C:\xampp\htdocs\database\counter.php on line 8 My php file contains the following: <?php require($_SERVER["DOCUMENT_ROOT"]."/database/config/db_config.php"); $connection = @mysql_connect($db_host,$db_user, $db_password) or die("error connecting"); mysql_select_db($db_name, $connection); $query = "SELECT * FROM counter"; echo $query $result = mysql_query($query, $connection) or die(mysql_error()); echo $result $views = mysql_result($result, 0, "num_views"); echo $views $views++; $query = "UPDATE counter SET num_views = $views"; mysql_query($query, $connection) or die(mysql_error()); echo "This page has been viewed ".$views." times."; ?> I created the counter table in phpmyadmin and it has the following details: # Name Type Collation Attributes Null Default Extra Action 1 num_views int(5) UNSIGNED No 0 Change Drop Browse distinct values Any help appreciated. Regards, Guy Brown counter.php
×
×
  • 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.