Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

zoonder

Members
  • Joined

  • Last visited

  1. . Yes this is true. $query = "SELECT count(albumID) as count_of_albumID FROM album"; The above will count the number of non-NULL values in the column "albumID". Where as the SQL max function will return the highest value in the column. $query = "SELECT max(albumID) as max_id FROM album";
  2. In a nutshell, yes. Apologies for any confusion - I changed the "SELECT" statement to make the example more clear. I could have used your original "SELECT max(albumID)..." and done this: echo $arrRow['max(albumID)']; Instead I modified the SQL so that max(albumID) was assigned to a column alias "max_id" . The "mysqli_fetch_array" function returns two arrays by default one is an indexed array and the other is an associative array. You can specify what is returned by using the result type parameter of mysqli_fetch_array like this: $arrRow = mysqli_fetch_array($rsAlbums,MYSQLI_ASSOC); // for an ASSOCIATIVE ARRAY ONLY $arrRow = mysqli_fetch_array($rsAlbums,MYSQLI_NUM); // for an INDEXED ARRAY ONLY $arrRow = mysqli_fetch_array($rsAlbums,MYSQLI_BOTH); // for both an INDEXED array and an ASSOCIATIVE ARRAY This can all be found in the (PHP Manual Page for mysqli_fetch_array). Try using one of the three examples above in your code - To see the arrays in a human readable format use print_r($arrRow); The associative array uses the field name(s) from the "SELECT" statement as the key - hence I was able to refer to the key "max_id".
  3.    Frisby reacted to a post in a topic: Fetch data from db with var and then echo?
  4. You would do it something like this: <?php include("secretpwordsclickmeooohoh.php"); # This will get the number of albums. $query = "SELECT max(albumID) as max_id FROM album"; $rsAlbums = mysqli_query($cxn,$query) or die ("Get number of albums query failed."); while ($arrRow = mysqli_fetch_array($rsAlbums)) { echo $arrRow['max_id']; } ?> mysqli_query will execute a query and return a result set. You then need to execute mysqli_fetch_array (or some other mysqli_fetch) to return one row from the result set. In the example I have looped through the result set in a while loop. Each iteration of the loop fetches a the next row. In your example there will only be one row returned - so technically you could remove the while loop and do this: <?php include("secretpwordsclickmeooohoh.php"); # This will get the number of albums. $query = "SELECT max(albumID) as max_id FROM album"; $rsAlbums = mysqli_query($cxn,$query) or die ("Get number of albums query failed."); $arrRow = mysqli_fetch_array($rsAlbums); echo $arrRow['max_id']; ?> Hope this helps.
  5. also I would change the following if (!subject) to if (!$subject) and do the same for every "if" statement that does not have a $ preceding the variable name.
  6. A couple of starters - the form submit is different in both snippets. This is present in index.php (assuming its the first snippet in your post. When submitted it should load sendmail.php <form method="post" action="sendmail.php"> This is present in sendmail.php snippet in your post. When submitted it should load index.php <form method="post" action="index.php"> Only sendmail.php contains any processing and it looks incorrect. The values submitted from the form would normally be done something like this: $subject = $_POST['subject']; Finally index.php contains no processing. Hope this helps get you started
  7. zoonder replied to MG1878's topic in Server Side
    I've had a look at the regular expressions, and the regex that checks URLs has created the problem. In version provided its mandatory for the the URL to start with "http" or "https" at the start of the string. Try modifying the code to this in the validaion part of the script: elseif (!empty($_POST['url']) && !preg_match('/^((http|https):\/\/)*(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(\d+))?\/?/i', $_POST['url'])) $error_msg .= "Invalid website url."; I have added some extra brackets like this: ^((http|https):\/\/)* Broken down then... ^ matches at the start of the string ( is a start of a grouping | is "or" so its http or https ) is the end of the grouping * is zero, one, or more occurences \ is an escape character So what we're matching is http:// or https:// at the start of a string. As I've specified it to match zero or more times the expression will match things like: http://zoonder.co.uk zoonder.co.uk https://zoonder.co.uk news.bbc.co.uk I hope this helps
  8. zoonder replied to MG1878's topic in Server Side
    Interesting that it didnt work from my test page (not posting link to test page as I will remove once this is resolved) - I have tried again and received an email, so I'm thinking it's possibly related to the validation. What values did you enter on the form?
  9. zoonder replied to MG1878's topic in Server Side
    I've checked the code on my server - it emails me with the form data. I've noticed that your form submits to "/contact-us.php" Perhaps change it to this: <form action="contact-us.php" method="post" id="main"> Let us know how you get on.
  10. zoonder replied to MG1878's topic in Server Side
    Without seeing the original PHP code I would guess that the variables become before the HTML is output. If you could post the original PHP code I'll take a look. For the moment you could just move the block of code back to where it was, and do the following: if (mail($yourEmail,$subject,$message,$headers)) {//echo '<p>Your mail was successfully sent.</p>';} else {echo '<p>Your mail could not be sent this time.</p>';} I have "commented out" the output of the mail sent message. This should solve the issue and prevent the message from being displayed - except when the mail fails. A slightly more effective method might be to have the form submit to a "thank you" page and handle the processing there. Another alternative is to create a variable to determine if the mail was sent. Eg. //Place this variable at the top of you php script $blnProcessed = false; //put this code back where you found it if (mail($yourEmail,$subject,$message,$headers)) {$blnProcessed = true;} else {echo '<p>Your mail could not be sent this time.</p>';} Only if the mail is sent will the variable will be set to true. Then as Mikec1uk suggests place the mail sent message above the form. <?php if ($blnProcessed == true) { echo '<p>Your mail was successfully sent.</p>'; } ?> You may want to tweak the code.
  11. zoonder replied to MG1878's topic in Server Side
    Looks ok in FF3 (V1.0.15). In IE7 it messes up after the form has been submitted. I would try removing the output message that says "Your mail was sucessfully sent" - the message is output before the start of the HTML document.
  12. zoonder replied to Rach1983's topic in Server Side
    I've used both PHP and ASP.NET for enterprise solutions - I have a bias to PHP because I've programmed in it for over 10 years, and it can run on just about any server. I've also tried my hand at ASP.NET too, but only have a few years commercial experience in that. ASP.NET uses the Microsoft .NET framework which is largely good. The tools offered for web development in MS Visual Studio 2005 are poor and over-complicate the whole web development process. The C# programming language is a good language to work with but I can't say the same for VB.NET. It is just a matter of preference; VB is possibly an easier language (compared to C#) to learn as a beginner. PHP is a great programming language for the web; it's an easy language to learn and also integrates well with other technologies. I have used PHP to implement corporate solutions that interact with Active Directory, Oracle, MSSQL Server, and ERP systems. The solutions were all run on a Windows 2003 Server. PHP also has a number of frameworks similar to what .NET offers. Both PHP and ASP.NET are easy to learn. Also look at license costs, and the costs of development tools for both. I develop PHP using open source tools - so the cost is nothing or minimal. There are beta versions of Visual Studio and developer versions of the Microsoft products, and if I'm not mistaken there may be some "light" versions for students, or people just wanting to learn or evaluate. From a business perspective you would tend to stick where the bulk of your experience lies unless there was an overwhelming advantage to be gained. So if you had a team of ASP developers you'd go the ASP route rather than re-train your team. For a project think about what benefits may be gained in the long term by using one technology over another. Sometimes a project can lead on to bigger things, so something that starts out as a basic stock database for example may need linking with serveral other technologies in the future. I've had no problems using PHP and open source technology in a Microsoft dominated environment, but I cant help think that some of the programming might have been easier using ASP.NET in a native framework. That said upgrade paths of underlying technology can also have an influence - for this I've found PHP to be very robust. Hope this helps
  13. zoonder replied to Milli05's topic in Server Side
    I use XAMPP on Vista - I have used WAMP, but found XAMPP more suitable for my requirements. I posted tutorial for XAMPP configuration - I know this doesn't solve your problem with WAMP, but it may provide an alternative solution. It also includes XDebug configuration and an introduction to Eclipse (PDT). Anyway the link can be found on this post: PHP Web Development Tutorial Part 1 Hope the problem gets resolved
  14. I had a quick look at your code last night, and noticed that you have built your own 'Accordion' effect using the slideToggle. If you only want one part of the 'accordion' open at any time it could be easier you use the 'Accordion' plugin, and set animated to false. This will make your tabs expand and contract only (no fancy slide effect). eg. <script type="text/javascript"> $(document).ready(function() { $('#accordian').accordion({ header: 'h1', animated: false }); }); </script> The CSS would need adjusting too - #accordian div would be the content, and #accordian h1 would be the tab. There's further info on the jQuery UI pages it also includes information on having more than one part of the 'Accordion' open at once. Here's the link for the 'Accordion' : jQuery UI - Accordion Finally I would recommend linking to Google Apis or JQuery for your jQuery libraries and styles. eg. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script> The javascript is cached in browsers and indexed by domain - It will reduce download time if someone already has a cached version of the jQuery library from the above. Sorry I can't completely solve your problem, but hope this helps
  15. Hi Sam, Welcome to the forum
  16. Welcome to the forum Ian

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.