Announcement

Collapse
No announcement yet.

database problem with php

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • database problem with php

    lets say i have a form with input "url" as name. I want to get dns records for that. The url outputs some information from the php coding with the following results as history, item and so on and i have added variable to process them to databse. But the problem is that dbase isnt working as it shows empty query. Because the given below variable values arent shown as input in the form, they are output taken from the "url" name input in the form.
    <form>
    <input type="text" name="url">
    </form>
    HTML Code:
    $history = "history";
    $item= "new here";
    $type="very old";
    $good = "old";
    $new= "new";
    
    $user_query= "INSERT INTO udbase_form( history, item, type, good, new), 
    VALUES('$history', '$item', '$type', '$good', '$new')"; 
    }
    if($myconn->query($user_query ===true)){
    echo "Tables created successfully";
    } else {
    echo "tables cant be created." .$myconn->error;
    }
    mysqli::query(): Empty query in /home//public_html/b/.php on line --
    tables cant be created

    How do i solve this problem as I am getting ouput of "url" in variable form and now i want to process them to dbase.
    Last edited by letmelearn; 08-19-2015, 04:09 PM.

  • #2
    Hi,

    it should be

    Code:
    if($myconn->query($user_query)/* this should not be appended into the query, but read the result of the query. */ ===true) {
    also noticed with your actual query you are writing the value $history, not the value stored in $history, this is because you have quotes around the variables.

    it should be

    Code:
    $user_query= "INSERT INTO udbase_form( history, item, type, good, new), 
    VALUES($history, $item, $type, $good, $new)";
    Who needs a Signature?

    Comment


    • #3
      Actually it should be

      Code:
      $user_query= "INSERT INTO udbase_form (history, item, type, good, new)
      VALUES ($history, $item, $type, $good, $new)";
      Watch the comma right before values
      Have a Script or Snippet you want to share?

      WWW Standards: HTML 4.01,
      HTML 5, CSS2.1, CSS3, XHTML 1.0
      PHP Standards: PHP Standards

      Comment

      Working...
      X