<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CS310 Quiz 2 Solution and Discussion]]></title><description><![CDATA[<p dir="auto">_______ statement is used to create database named MyDatabase in MySQL.</p>
<pre><code>CREATE DATABASE databasename;

</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1565363349213-79eb9f19-376a-41d7-b9e9-f2a2c4dc5743-image.png" alt="79eb9f19-376a-41d7-b9e9-f2a2c4dc5743-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//topic/337/cs310-quiz-2-solution-and-discussion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 19:59:58 GMT</lastBuildDate><atom:link href="https://community.secnto.com//topic/337.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Aug 2019 15:12:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:47:18 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/874">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">What SQL clause is used to restrict the rows returned by a query?</p>
</blockquote>
<p dir="auto">The SQL clause used to restrict or filter rows based on a specific condition is the <strong>WHERE</strong> clause.</p>
<p dir="auto">It is placed after the <code>FROM</code> clause and before any grouping or sorting clauses. Only the rows that meet the specified criteria (where the condition evaluates to <strong>TRUE</strong>) will be included in the result set.</p>
<h3>Basic Syntax</h3>
<pre><code class="language-sql">SELECT column1, column2
FROM table_name
WHERE condition;

</code></pre>
<h3>Examples of Usage</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Requirement</th>
<th>SQL Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Exact Match</strong></td>
<td><code>WHERE city = 'London'</code></td>
</tr>
<tr>
<td><strong>Numeric Range</strong></td>
<td><code>WHERE age &gt; 18</code></td>
</tr>
<tr>
<td><strong>Pattern Matching</strong></td>
<td><code>WHERE name LIKE 'A%'</code></td>
</tr>
<tr>
<td><strong>Multiple Conditions</strong></td>
<td><code>WHERE price &lt; 100 AND stock &gt; 0</code></td>
</tr>
</tbody>
</table>
<h3>A Quick Distinction: WHERE vs. HAVING</h3>
<ul>
<li><strong>WHERE:</strong> Filters individual rows <strong>before</strong> any grouping occurs.</li>
<li><strong>HAVING:</strong> Filters groups <strong>after</strong> the <code>GROUP BY</code> clause has been applied.</li>
</ul>
]]></description><link>https://community.secnto.com//post/8292</link><guid isPermaLink="true">https://community.secnto.com//post/8292</guid><dc:creator><![CDATA[Zohaib Malik]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:47:18 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:59:04 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/866">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">If we want to show all the session variable values for a user session then following code will be used.</p>
</blockquote>
<p dir="auto">To see every variable currently stored in a user’s session, you use the <strong><code>print_r()</code></strong> or <strong><code>var_dump()</code></strong> function on the <strong><code>$_SESSION</code></strong> superglobal.</p>
<p dir="auto">These functions allow you to output the entire contents of the associative array in a readable format, which is extremely helpful for debugging.</p>
<h3>The Code</h3>
<pre><code class="language-php">&lt;?php
session_start(); // You must always start the session first

// Option 1: Using print_r (Cleanest for reading)
echo "&lt;pre&gt;";
print_r($_SESSION);
echo "&lt;/pre&gt;";

// Option 2: Using var_dump (Provides more detail like data types)
var_dump($_SESSION);
?&gt;

</code></pre>
<hr />
<h3>Why use <code>&lt;pre&gt;</code>?</h3>
<p dir="auto">When using <code>print_r()</code> or <code>var_dump()</code>, wrapping the code in HTML <code>&lt;pre&gt;</code> (preformatted text) tags is a “pro-tip.” It forces the browser to display the array with proper indentation and line breaks, making it much easier for you to read than a single long line of text.</p>
<h3>Common Session Commands Summary</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Purpose</th>
<th>Command</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Start/Resume</strong></td>
<td><code>session_start();</code></td>
</tr>
<tr>
<td><strong>Show All Values</strong></td>
<td><code>print_r($_SESSION);</code></td>
</tr>
<tr>
<td><strong>Check if a variable exists</strong></td>
<td><code>isset($_SESSION['key']);</code></td>
</tr>
<tr>
<td><strong>Clear all values</strong></td>
<td><code>session_unset();</code></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>Would you like me to show you how to loop through the session variables using a <code>foreach</code> loop if you want to format the output as a list?</strong></p>
]]></description><link>https://community.secnto.com//post/8300</link><guid isPermaLink="true">https://community.secnto.com//post/8300</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:59:04 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:58:13 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/867">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Which of the following PHP syntax is used to remove all HTML tags from a string? CS310</p>
</blockquote>
<p dir="auto">To remove all HTML tags from a string in PHP, you use the <strong><code>filter_var()</code></strong> function with the <strong><code>FILTER_SANITIZE_STRING</code></strong> constant or the <strong><code>strip_tags()</code></strong> function.</p>
<h3>1. Using <code>filter_var()</code> (Standard for sanitization)</h3>
<p dir="auto">This is the modern approach for cleaning input data.</p>
<pre><code class="language-php">$input = "&lt;h1&gt;Hello&lt;/h1&gt; &lt;p&gt;World!&lt;/p&gt;";
$clean = filter_var($input, FILTER_SANITIZE_STRING);
// Result: "Hello World!"

</code></pre>
<p dir="auto"><em>Note: As of PHP 8.1.0, <code>FILTER_SANITIZE_STRING</code> is deprecated. While still common in exam questions (like CS310), the modern replacement is <code>htmlspecialchars()</code> or <code>strip_tags()</code>.</em></p>
<h3>2. Using <code>strip_tags()</code> (Dedicated function)</h3>
<p dir="auto">This is a very common and straightforward function specifically designed to strip HTML and PHP tags from a string.</p>
<pre><code class="language-php">$input = "&lt;b&gt;Bold Text&lt;/b&gt;";
echo strip_tags($input); 
// Result: "Bold Text"

</code></pre>
<hr />
<h3>Comparison of Methods</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Method</th>
<th>Best Use Case</th>
<th>Key Feature</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><code>strip_tags()</code></strong></td>
<td>General purpose stripping</td>
<td>Allows you to specify “allowable tags” that should NOT be removed.</td>
</tr>
<tr>
<td><strong><code>filter_var()</code></strong></td>
<td>Data sanitization pipelines</td>
<td>Part of a unified filtering system for emails, URLs, and integers.</td>
</tr>
<tr>
<td><strong><code>htmlspecialchars()</code></strong></td>
<td>Security (XSS prevention)</td>
<td>Doesn’t remove tags, but converts them to plain text so the browser won’t execute them.</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>Would you like me to show you how to use <code>strip_tags()</code> while keeping certain tags (like <code>&lt;b&gt;</code> or <code>&lt;i&gt;</code>) intact?</strong></p>
]]></description><link>https://community.secnto.com//post/8299</link><guid isPermaLink="true">https://community.secnto.com//post/8299</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:58:13 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:57:34 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/868">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">How will we retrieve the value of session variable set in the following PHP code?</p>
</blockquote>
<p dir="auto">Retrieve session variable<br />
Answer: (d) $_SESSION[“color”];$<br />
The session variable is stored in the superglobal array $_SESSION with the key “color”. To retrieve its value, you must access this specific array using the same key. The other options use incorrect array names or incorrect keys.</p>
<p dir="auto">To retrieve a session variable in PHP, you access the <strong><code>$_SESSION</code></strong> superglobal array using the specific key (name) that was used to set it.</p>
<h3>The Syntax</h3>
<p dir="auto">If your session variable was set like this:<br />
<code>$_SESSION['username'] = "Alex";</code></p>
<p dir="auto">You retrieve it like this:</p>
<pre><code class="language-php">echo $_SESSION['username'];

</code></pre>
<hr />
<h3>Important Steps for Retrieval</h3>
<p dir="auto">For the value to be accessible, you must follow these two rules:</p>
<ol>
<li><strong>Start the Session:</strong> You must call <strong><code>session_start();</code></strong> at the very top of your PHP file before trying to access the <code>$_SESSION</code> array.</li>
<li><strong>Check if it Exists:</strong> It is best practice to use <code>isset()</code> to avoid an “Undefined index” error in case the session has expired or wasn’t set.</li>
</ol>
<p dir="auto"><strong>Example Code:</strong></p>
<pre><code class="language-php">&lt;?php
session_start(); // Mandatory to access session data

if(isset($_SESSION['username'])) {
    echo "Welcome back, " . $_SESSION['username'];
} else {
    echo "User is not logged in.";
}
?&gt;

</code></pre>
<h3>Summary of Session Functions</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Action</th>
<th>PHP Command</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Start/Resume</strong></td>
<td><code>session_start();</code></td>
</tr>
<tr>
<td><strong>Set/Retrieve</strong></td>
<td><code>$_SESSION['key']</code></td>
</tr>
<tr>
<td><strong>Remove one variable</strong></td>
<td><code>unset($_SESSION['key']);</code></td>
</tr>
<tr>
<td><strong>Destroy all data</strong></td>
<td><code>session_destroy();</code></td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>Would you like me to show you the specific code to set a session variable first, or perhaps how to destroy a session when a user logs out?</strong></p>
]]></description><link>https://community.secnto.com//post/8298</link><guid isPermaLink="true">https://community.secnto.com//post/8298</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:57:34 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:54:58 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/869">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">_______ statement is used to add a new record to a MySQL table</p>
</blockquote>
<p dir="auto">The <strong><code>INSERT INTO</code></strong> statement is used to add a new record (row) to a MySQL table.</p>
<h3>Basic Syntax</h3>
<p dir="auto">There are two primary ways to write this statement:</p>
<p dir="auto"><strong>1. Specifying both column names and values:</strong><br />
This is the safest method as it ensures data goes into the correct fields.</p>
<pre><code class="language-sql">INSERT INTO table_name (column1, column2, column3)
VALUES (value1, value2, value3);

</code></pre>
<p dir="auto"><strong>2. Specifying values only:</strong><br />
You can omit column names if you are providing values for <strong>every</strong> column in the exact order they appear in the table.</p>
<pre><code class="language-sql">INSERT INTO table_name
VALUES (value1, value2, value3);

</code></pre>
<hr />
<h3>Practical Example</h3>
<p dir="auto">If you have a table named <code>Users</code>, you would add a new person like this:</p>
<pre><code class="language-sql">INSERT INTO Users (username, email, age)
VALUES ('jdoe', 'john@example.com', 25);

</code></pre>
<h3>Key Tips</h3>
<ul>
<li><strong>Strings:</strong> Always wrap text/string values in single quotes (e.g., <code>'Hello'</code>).</li>
<li><strong>Numbers:</strong> Numeric values do not require quotes.</li>
<li><strong>Auto-Increment:</strong> If your table has an <code>id</code> column set to <code>AUTO_INCREMENT</code>, you don’t need to include it in your <code>INSERT</code> statement; MySQL will generate the number for you automatically.</li>
</ul>
]]></description><link>https://community.secnto.com//post/8297</link><guid isPermaLink="true">https://community.secnto.com//post/8297</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:54:58 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:53:32 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/870">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Which of the following PHP syntax is used to remove all illegal characters from a URL?</p>
</blockquote>
<p dir="auto">To remove all illegal characters from a URL in PHP, you use the <strong><code>filter_var()</code></strong> function combined with the <strong><code>FILTER_SANITIZE_URL</code></strong> constant.</p>
<h3>The Syntax</h3>
<pre><code class="language-php">$url = "https://example.com/search?q=hello world!";
$clean_url = filter_var($url, FILTER_SANITIZE_URL);

</code></pre>
<h3>How it Works</h3>
<p dir="auto">This specific filter is designed to clean a string by removing characters that are not permitted in a URL. It allows all letters, digits, and the following special characters:<br />
<code>$-_.+!*'(),{}|\\^~[]</code>&lt;&gt;#%";/?:@&amp;=`</p>
<h3>Key Differences in URL Handling</h3>
<p dir="auto">It is important to distinguish between <strong>sanitizing</strong> (cleaning) and <strong>validating</strong> (checking):</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Function Goal</th>
<th>Filter Constant</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Sanitize</strong></td>
<td><code>FILTER_SANITIZE_URL</code></td>
<td>Returns a “clean” string with illegal characters removed.</td>
</tr>
<tr>
<td><strong>Validate</strong></td>
<td><code>FILTER_VALIDATE_URL</code></td>
<td>Returns the URL if it’s in a valid format, or <code>false</code> if it isn’t.</td>
</tr>
</tbody>
</table>
<hr />
<p dir="auto"><strong>Would you like me to show you how to combine both to first clean a URL and then check if the result is actually valid?</strong></p>
]]></description><link>https://community.secnto.com//post/8296</link><guid isPermaLink="true">https://community.secnto.com//post/8296</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:53:32 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:52:31 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/871">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">In PHP, in order to access MySQL database you will use:<br />
<img src="/assets/uploads/files/1565364324699-d5906239-9553-40a9-980c-d058f7441e37-image.png" alt="d5906239-9553-40a9-980c-d058f7441e37-image.png" class=" img-fluid img-markdown" /></p>
</blockquote>
<p dir="auto"><strong>Answer: mysqli_connect() function</strong></p>
<p dir="auto">In modern PHP, you have two primary, recommended ways to access a MySQL database. While older versions used the <code>mysql_</code> extension, that has been deprecated and removed for security reasons.</p>
<p dir="auto">Today, you should use one of the following:</p>
<h3>1. MySQLi (MySQL Improved)</h3>
<p dir="auto">This is a driver specifically designed for MySQL databases. It supports both <strong>procedural</strong> (using functions) and <strong>object-oriented</strong> (using classes) programming styles.</p>
<ul>
<li><strong>Best for:</strong> Projects that only use MySQL and want to take advantage of MySQL-specific features like stored procedures.</li>
</ul>
<pre><code class="language-php">// Object-oriented example
$conn = new mysqli("localhost", "username", "password", "database");

</code></pre>
<h3>2. PDO (PHP Data Objects)</h3>
<p dir="auto">PDO is a database abstraction layer. It provides a consistent way to interact with many different types of databases (MySQL, PostgreSQL, SQLite, etc.).</p>
<ul>
<li><strong>Best for:</strong> Flexibility. If you ever decide to switch your database from MySQL to another system, you won’t have to rewrite your entire data access code.</li>
</ul>
<pre><code class="language-php">// PDO example
$dsn = "mysql:host=localhost;dbname=testdb";
$conn = new PDO($dsn, "username", "password");

</code></pre>
<hr />
<h3>Comparison at a Glance</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Feature</th>
<th>MySQLi</th>
<th>PDO</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Database Support</strong></td>
<td>MySQL only</td>
<td>12 different drivers</td>
</tr>
<tr>
<td><strong>Programming Style</strong></td>
<td>Procedural &amp; OO</td>
<td>Object-Oriented only</td>
</tr>
<tr>
<td><strong>Prepared Statements</strong></td>
<td>Supported (Secure)</td>
<td>Supported (Secure)</td>
</tr>
<tr>
<td><strong>Named Parameters</strong></td>
<td>Not supported</td>
<td>Supported</td>
</tr>
</tbody>
</table>
<blockquote>
<p dir="auto"><strong>Security Note:</strong> Regardless of which you choose, always use <strong>Prepared Statements</strong> to protect your database from SQL Injection attacks.</p>
</blockquote>
]]></description><link>https://community.secnto.com//post/8295</link><guid isPermaLink="true">https://community.secnto.com//post/8295</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:52:31 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:49:22 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/872">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Which of the following PHP function is used to validate and sanitize the data?</p>
</blockquote>
<p dir="auto">The PHP function used for both validating and sanitizing data is <strong><code>filter_var()</code></strong>.</p>
<p dir="auto">This function is highly versatile because it allows you to check if data is in the correct format (Validation) or remove illegal characters from data (Sanitization) simply by changing the “filter” flag you pass to it.</p>
<h3>1. Validation</h3>
<p dir="auto">Validation checks if the data meets certain criteria. If it doesn’t, the function returns <code>false</code>.</p>
<ul>
<li><strong>Example:</strong> Checking if an email is valid.</li>
</ul>
<pre><code class="language-php">if (filter_var("test@example.com", FILTER_VALIDATE_EMAIL)) {
    echo "Valid email address.";
}

</code></pre>
<h3>2. Sanitization</h3>
<p dir="auto">Sanitization cleans the data by removing or encoding characters that could be harmful or unwanted.</p>
<ul>
<li><strong>Example:</strong> Removing HTML tags from a string.</li>
</ul>
<pre><code class="language-php">$clean_string = filter_var("&lt;h1&gt;Hello!&lt;/h1&gt;", FILTER_SANITIZE_STRING);
// Result: "Hello!"

</code></pre>
<hr />
<h3>Common Filter Constants</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Filter Constant</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><code>FILTER_VALIDATE_EMAIL</code></strong></td>
<td>Validates an email address.</td>
</tr>
<tr>
<td><strong><code>FILTER_VALIDATE_INT</code></strong></td>
<td>Validates an integer.</td>
</tr>
<tr>
<td><strong><code>FILTER_VALIDATE_URL</code></strong></td>
<td>Validates a URL.</td>
</tr>
<tr>
<td><strong><code>FILTER_SANITIZE_EMAIL</code></strong></td>
<td>Removes all characters except letters, digits and !#$%&amp;'*±/=?^_`{|}~@.[]. |</td>
</tr>
</tbody>
</table>
<h3>Why use <code>filter_var()</code>?</h3>
<p dir="auto">It is much safer and more reliable than using custom Regular Expressions (Regex). Using these built-in filters helps protect your application against common security vulnerabilities like <strong>Cross-Site Scripting (XSS)</strong> and <strong>SQL Injection</strong>.</p>
]]></description><link>https://community.secnto.com//post/8294</link><guid isPermaLink="true">https://community.secnto.com//post/8294</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:48:37 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/873">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">Use …… to add table in the database</p>
</blockquote>
<p dir="auto">To add a new table to a database, you use the <strong><code>CREATE TABLE</code></strong> statement.</p>
<p dir="auto">This command defines the table name and specifies the columns, including their data types (e.g., <code>INT</code>, <code>VARCHAR</code>, <code>DATE</code>) and any constraints (e.g., <code>PRIMARY KEY</code>, <code>NOT NULL</code>).</p>
<h3>Basic Syntax</h3>
<pre><code class="language-sql">CREATE TABLE table_name (
    column1 datatype constraint,
    column2 datatype constraint,
    column3 datatype constraint
);

</code></pre>
<h3>Practical Example</h3>
<p dir="auto">If you wanted to create a table to store student information, the query would look like this:</p>
<pre><code class="language-sql">CREATE TABLE Students (
    StudentID int PRIMARY KEY,
    FirstName varchar(50),
    LastName varchar(50),
    EnrollmentDate date
);

</code></pre>
<h3>Key Points to Remember</h3>
<ul>
<li><strong>Unique Name:</strong> The table name must be unique within the database.</li>
<li><strong>Data Types:</strong> You must define what kind of data each column will hold.</li>
<li><strong>Primary Key:</strong> It is best practice to include a Primary Key to uniquely identify each row in your table.</li>
</ul>
]]></description><link>https://community.secnto.com//post/8293</link><guid isPermaLink="true">https://community.secnto.com//post/8293</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:48:37 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 23 Jan 2026 14:47:18 GMT]]></title><description><![CDATA[<p dir="auto">said in <a href="/post/874">CS310 Quiz 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">What SQL clause is used to restrict the rows returned by a query?</p>
</blockquote>
<p dir="auto">The SQL clause used to restrict or filter rows based on a specific condition is the <strong>WHERE</strong> clause.</p>
<p dir="auto">It is placed after the <code>FROM</code> clause and before any grouping or sorting clauses. Only the rows that meet the specified criteria (where the condition evaluates to <strong>TRUE</strong>) will be included in the result set.</p>
<h3>Basic Syntax</h3>
<pre><code class="language-sql">SELECT column1, column2
FROM table_name
WHERE condition;

</code></pre>
<h3>Examples of Usage</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Requirement</th>
<th>SQL Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Exact Match</strong></td>
<td><code>WHERE city = 'London'</code></td>
</tr>
<tr>
<td><strong>Numeric Range</strong></td>
<td><code>WHERE age &gt; 18</code></td>
</tr>
<tr>
<td><strong>Pattern Matching</strong></td>
<td><code>WHERE name LIKE 'A%'</code></td>
</tr>
<tr>
<td><strong>Multiple Conditions</strong></td>
<td><code>WHERE price &lt; 100 AND stock &gt; 0</code></td>
</tr>
</tbody>
</table>
<h3>A Quick Distinction: WHERE vs. HAVING</h3>
<ul>
<li><strong>WHERE:</strong> Filters individual rows <strong>before</strong> any grouping occurs.</li>
<li><strong>HAVING:</strong> Filters groups <strong>after</strong> the <code>GROUP BY</code> clause has been applied.</li>
</ul>
]]></description><link>https://community.secnto.com//post/8292</link><guid isPermaLink="true">https://community.secnto.com//post/8292</guid><dc:creator><![CDATA[Zohaib Malik]]></dc:creator><pubDate>Fri, 23 Jan 2026 14:47:18 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:26:38 GMT]]></title><description><![CDATA[<p dir="auto">What SQL clause is used to restrict the rows returned by a query?<br />
<img src="/assets/uploads/files/1565364391651-55244ad6-5866-47d3-910c-3b933ed475c1-image.png" alt="55244ad6-5866-47d3-910c-3b933ed475c1-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/874</link><guid isPermaLink="true">https://community.secnto.com//post/874</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:26:38 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:26:14 GMT]]></title><description><![CDATA[<p dir="auto">Use …… to add table in the database<br />
<img src="/assets/uploads/files/1565364373316-400e9f0b-b647-4f63-9b6b-cd1c2d8011d0-image.png" alt="400e9f0b-b647-4f63-9b6b-cd1c2d8011d0-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/873</link><guid isPermaLink="true">https://community.secnto.com//post/873</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:26:14 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:25:51 GMT]]></title><description><![CDATA[<p dir="auto">Which of the following PHP function is used to validate and sanitize the data?</p>
<p dir="auto"><img src="/assets/uploads/files/1565364344000-13124763-0ebd-4cd5-b247-eafeb3549a8e-image.png" alt="13124763-0ebd-4cd5-b247-eafeb3549a8e-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/872</link><guid isPermaLink="true">https://community.secnto.com//post/872</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:25:51 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:25:32 GMT]]></title><description><![CDATA[<p dir="auto">In PHP, in order to access MySQL database you will use:<br />
<img src="/assets/uploads/files/1565364324699-d5906239-9553-40a9-980c-d058f7441e37-image.png" alt="d5906239-9553-40a9-980c-d058f7441e37-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/871</link><guid isPermaLink="true">https://community.secnto.com//post/871</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:25:32 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:25:11 GMT]]></title><description><![CDATA[<p dir="auto">Which of the following PHP syntax is used to remove all illegal characters from a URL?</p>
<p dir="auto"><img src="/assets/uploads/files/1565364302159-08599c0a-7636-43b5-8fd6-115cd16c6eec-image.png" alt="08599c0a-7636-43b5-8fd6-115cd16c6eec-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/870</link><guid isPermaLink="true">https://community.secnto.com//post/870</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:25:11 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:24:40 GMT]]></title><description><![CDATA[<p dir="auto">_______ statement is used to add a new record to a MySQL table</p>
<p dir="auto"><img src="/assets/uploads/files/1565364278185-d67192ba-7d16-406f-af74-00d00b7918b8-image.png" alt="d67192ba-7d16-406f-af74-00d00b7918b8-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/869</link><guid isPermaLink="true">https://community.secnto.com//post/869</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:24:40 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:24:16 GMT]]></title><description><![CDATA[<p dir="auto">How will we retrieve the value of session variable set in the following PHP code?<br />
$_SESSION[“color”] = “green”;</p>
<p dir="auto"><img src="/assets/uploads/files/1565364251027-448ac04c-61a2-4da2-a13b-0de162c95fc6-image.png" alt="448ac04c-61a2-4da2-a13b-0de162c95fc6-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/868</link><guid isPermaLink="true">https://community.secnto.com//post/868</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:24:16 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:23:54 GMT]]></title><description><![CDATA[<p dir="auto">Which of the following PHP syntax is used to remove all HTML tags from a string? CS310<br />
<img src="/assets/uploads/files/1565364230901-6732c0fa-a97e-46bd-8cce-7a938fa8db76-image.png" alt="6732c0fa-a97e-46bd-8cce-7a938fa8db76-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/867</link><guid isPermaLink="true">https://community.secnto.com//post/867</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:23:54 GMT</pubDate></item><item><title><![CDATA[Reply to CS310 Quiz 2 Solution and Discussion on Fri, 09 Aug 2019 15:16:48 GMT]]></title><description><![CDATA[<p dir="auto">If we want to show all the session variable values for a user session then following code will be used.</p>
<p dir="auto">print_r($_SESSION);</p>
<p dir="auto"><img src="/assets/uploads/files/1565363800549-12e46637-e0cf-4b8a-8e09-eb0600a3614b-image.png" alt="12e46637-e0cf-4b8a-8e09-eb0600a3614b-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/866</link><guid isPermaLink="true">https://community.secnto.com//post/866</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Fri, 09 Aug 2019 15:16:48 GMT</pubDate></item></channel></rss>