-10

This question already has an answer here:

  • connection to database file contains:

        $server="localhost";
        $login="root";
        $pass="";
        $database="floweritem";
    
        $con=mysqli_connect($server,$login,$pass,$database);
        if(mysqli_connect_errno()){
        echo "Failed connect to MYSQL".mysqli_connect_error();
        }
    
  • PHP

        <?php
        if(isset($_POST['submit'])){
        $Name=mysqli_real_escape_string($con,$_POST['Name']);
        $Desc=mysqli_real_escape_string($con,$_POST['Desc']);
        $Size=mysqli_real_escape_string($con,$_POST['Size']);
        $Price=mysqli_real_escape_string($con,$_POST['Price']);
    
    
        //no problwm with connection to table or database
        $sql="INSERT INTO `items`(`Name`,`Description`,`Size`,`Price`) 
        VALUES($Name,$Desc,$Size,$Price)";
        echo $Desc;
    
    
        if(mysqli_query($con,$sql)){ 
        echo "new record";
        }
        //always get wrong
        //can't find problem
        else{echo"Wrong";}
        mysqli_close($con);
        }
        ?>
    
  • shows $Desc And then Wrong

marked as duplicate by gnat, Martijn Pieters, Braiam, James, Shadow The Curly Braced Wizard Nov 21 '14 at 22:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • By... adding more details?? There is a question ban on questions that consist solely of code. That's because such questions are always missing at least one piece to be answerable. – Vogel612's Shadow Nov 21 '14 at 12:31
  • @Vogel612'sShadow thanx, I'm kinda new can u tell me how to fix it, I don't think so that I miss some parts – Pegasuss Nov 21 '14 at 12:38
  • 2
    The above seems to be lacking, well a "question". Start by trying to say what it should do and end with something better than "And then Wrong". – PeterJ Nov 21 '14 at 12:41
  • @PeterJ, Thanx so Much I Fix it – Pegasuss Nov 21 '14 at 12:45
5

There is no question.

Sometimes (note "sometimes") a "mostly" code only question can be acceptable if the question is very very simple, and only requires a short sentence to ask about the code provided.

However, in this case, you have not asked anything at all, you have just provided some code.

  • Is there an error in the code?
  • Does it not do what you want?
  • Do you want it to do something in addition to what it currently does?
  • etc etc

We could evaluate your code to try to ascertain what you want, and perhaps (for example) see a syntax error, however users won't use their time evaluating code trying to find out what you want or what is wrong. Usually it's impossible to guess or determine what is needed, and so is an unfair waste on users time trying to find out.

eg - Perhaps that syntax error was a secondary issue to what you originally wanted, so an answer pointing out the error would become wrong once you edit your question and make it more clear.

The first thing I see is you have no password assigned to your database credentials - $pass="";. In my "guessing", do I mention this? Or presume you left that out for security reasons not posting it publicly?
Already I am guessing, and proposing things you probably don't need.
A waste of mine and your time, which a simple question informing of what you want would resolve right away.

Enough information

I see you have provided some information, but I only see that when I've already begun to "evaluate" your code, and Stack is not about code evaluation or guessing, it's about answering a question.

In your code comments, you have:

//always get wrong
//can't find problem

And question text:

shows $Desc And then Wrong

You have to remember, while it may be clear in your mind what is wrong and what you need, we are new not only to your problem, but to your scenario and your code!
So you need to provide clear and concise information explaining what you want, which should be easy as you already know what is required as it's you who came here to ask the question you have.
So you need to actually ask it!

Also, your question here (MSE) is lacking in detail too. While your subject does ask a question, and arguably we know what you want, it is prudent to offer some details, in this case (eg) why you feel the original question was ok.

At the least a small sentence explaining any arguments you have as to why your original question was clear, or, even a link to the original question would have been good.

Some reading:

How to ask a good question?

What types of questions should I avoid asking?

Why do I see a message that my question does not meet quality standards?

More info

  • It was my first question and Thanx for ur info – Pegasuss Nov 21 '14 at 13:31
  • Being new is fine, everyone was when they joined, but you should make use of the links I have provided. It will help you avoid this issue, and others, in the future :) – James Nov 21 '14 at 13:32

Not the answer you're looking for? Browse other questions tagged .