Search the Community
Showing results for tags 'regexp'.
-
Good morning, I have a script and I'm trying to check whether it contains 1 character and whether it is between A and Z. preg_match() seems to be returning 0 and I'm not sure why. Here is my code: <?php $conn = mysqli_connect("localhost","root","","gaming") or die("Error: ".mysqli_error()); $qry = "SELECT game_id, release_date, game_desc, game_icon FROM games"; if(isset($_GET['letter'])) { /*if(strlen($_GET['letter']) == 1) { } else { header("Location: ?page=games"); }*/ $match = preg_match("/A-Z/", $_GET['letter']); echo $match; $qry .= " WHERE game_tag = '{$_GET['letter']}'"; } $sql = mysqli_query($conn, $qry) or die("Error: ".mysqli_error($conn)); $game_output = ""; while($row = mysqli_fetch_assoc($sql)) { $game_output .= "<div class='game_containers'>"; $game_output .= "<img src='images/game_icons/{$row['game_icon']}' alt='{$row['game_id']}' class='game_icon' />"; $game_output .= "<h3 class='game_header'>{$row['game_id']}</h3>"; $game_output .= "<p class='game_desc'>{$row['game_desc']}</p>"; $game_output .= "<hr />"; $game_output .= "Release Date: <span class='game_date'>{$row['release_date']}</span>"; $game_output .= "</div>"; } mysqli_close($conn); ?> When I echo $match, it always returns 0 even though $_GET['letter'] contains say 'M' or 'C' Any thoughts? Kind regards, L2c.
- 5 replies
-
- preg_match()
- regexp
-
(and 3 more)
Tagged with:
-
I had a multiple line text I want to get only first paragraph.like ......................................… <p>this is a paragraph number 1</p> <p>this is a paragraph number 2</p> ......................................… I want get only .................................. this is a paragraph number 1 ................................ How can I do that with RegExp. Please tell me.