Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6637505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:19:24+00:00 2026-05-25T23:19:24+00:00

This is my first PHP project so please guide how to debug effectively :

  • 0

This is my first PHP project so please guide how to debug effectively :

I created this form:

<form action="<?php $self ?>" method="post">
<div class="fname">
  <label for="name"><span> Name: </span>
  <input name="name" value= "<?php 
  if($error_count != 0) {
  echo $name;
  }// To avoid filling name again in case of error?>"
  type="text" cols="20" />
  </label>
</div>
<div class="femail">
  <label for="email"><span> Email: </span>
  <input name="email" value= "<?php 
  if($error_count != 0) {
  echo $email;
  }// To avoid filling email again in case of error?>" 
  type="text" cols="20" />
  </label>
</div>
<br/>
<textarea name="post" rows="5" cols="40"><?php 
  if($error_count != 0) {
  echo $post;
  }// To avoid filling textarea again in case of error?>
  </textarea>
<input name="send" type="hidden" />
<p>
  <input type="submit" value="shout" />
</p>

and following function to validate form (in a seperate file form_validation.php):

    <?php
function validate_shout($vmail,$vname,$vpost)
{

$error_count = 0; 

// To check email.
if(!preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/',$vmail)) {
echo "<p class =\"error\"> Please enter valid email address </p><br/>";
$error_count++;
}

// To check required fields
if($vname == NULL) {
echo "<p class =\"error\"> Oops!! You forgot to enter your name </p><br/>";
$error_count++;
}

if($vpost == NULL) {
echo "<p class =\"error\"> I guess your shout was blank </p><br/>";
$error_count++;
}

return $error_count;
}

?>

And used it in this way

if(isset($_POST['send'])) {

if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['post'])) {
echo "<p class=\"error\">Unable to connect to the database server at this time.</p>";
}
else {
 $name = htmlspecialchars(mysql_real_escape_string($_POST['name'])); 
 $email = htmlspecialchars(mysql_real_escape_string($_POST['email'])); 
 $post = htmlspecialchars(mysql_real_escape_string($_POST['post']));


$error_count = validate_shout($email,$name,$post);
//PHP code to add shout to database
if ($error_count == 0) 
{
$query = "INSERT INTO shouts SET name='$name', email='$email', post='$post';";
  • Now the problem is that it is not validating the textarea. other
    two are working fine. Code was working fine few days ago. but today
    when i opened it i found this problem.

One more thing i noticed was in phpMyadmin, as listed below

The additional features for working with linked tables have been deactivated. To find out why click here.

on click it displayed this:

$cfg['Servers'][$i]['pmadb'] ...    not OK [ Documentation ]
$cfg['Servers'][$i]['relation'] ...     not OK [ Documentation ]
General relation features: Disabled

$cfg['Servers'][$i]['table_info'] ...   not OK [ Documentation ]
Display Features: Disabled

$cfg['Servers'][$i]['table_coords'] ...     not OK [ Documentation ]
$cfg['Servers'][$i]['pdf_pages'] ...    not OK [ Documentation ]
Creation of PDFs: Disabled

$cfg['Servers'][$i]['column_info'] ...  not OK [ Documentation ]
Displaying Column Comments: Disabled
Browser transformation: Disabled

$cfg['Servers'][$i]['bookmarktable'] ...    not OK [ Documentation ]
Bookmarked SQL query: Disabled

$cfg['Servers'][$i]['history'] ...  not OK [ Documentation ]
SQL history: Disabled

$cfg['Servers'][$i]['designer_coords'] ...  not OK [ Documentation ]
Designer: Disabled

$cfg['Servers'][$i]['tracking'] ...     not OK [ Documentation ]
Tracking: Disabled 

I guess both the problems appeared together without any change in any settings or code by me. Although they look separate from each other.

Please help..

Main problem is why $post is not getting validated and why phpMyadmin is suddenly showing the above mentioned message

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:19:25+00:00Added an answer on May 25, 2026 at 11:19 pm

    The == NULL comparison will fail. Normally an empty string can also "equal" NULL. (You should preferrably write == "" anyway). But your textarea is unlikely to contain an really empty string. Just from your template I would assume it contains at least an newline, or a few more spaces even.

    In that case you don’t want to campare it against the empty string, but probe that it contains anything but spaces. To do so:

    if (strlen(trim($vpost))) {
    

    Anyway, to probe if a string contains anything, prefer strlen(). The trim() here is for filtering out whitespace prior to checking that.

    Some other notes about your code:

    • htmlspecialchars(mysql_real_escape_string( is the wrong order. The escape function is for the database. It must be applied immediately before concating it into SQL. Applying another encoding (html) afterwards might undo the SQL escaping.
    • <form action="<?php $self ?>" won’t work without some echo
    • And the email regex is just braindamaged. Use filter_var and the builtin FILTER_VALIDATE_EMAIL regex
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am studying OOP and this is my first study project. I created a
Okay, so this is my first project using PHP and MySQL and I thought
This is my first project using PHP and I've been stuck on this for
This is my first question :). Im writing a little twitter app in PHP
This is user.php: include(databse.php);//retrieving successfully first name and lastname from databse file into user.php
when I run this code for the first time <?php session_start(); echo SID; ?>
I downloaded a program implemented in Java (in this case, http://julian.togelius.com/mariocompetition2009/index.php ). I first
I'm about to begin work on my first ever PHP project -- building a
i newbie this my first project,I don't know how to resolve any problems about
I am planning my directory structure for a linux/apache/php web project like this: Only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.