2

I'm new to PHP and SQL, so this is something of a big bite for me...

I've got the following PHP code to connect to a server and select a specific Database inside the DBMS:

$server = 'localhost\SQLEXPRESS';
$link = mssql_connect($server, 'sa', 'asda');
mssql_select_db('Feedback', $link);

I have some values stored in variables like so:

$VariableA = $_POST['Field1'];
$VariableB = $_POST['Field2'];

How do I go about storing these variables into a table named 'Data', with the columns 'Name' and 'Rating'?

3
  • Please make use of the search. Commented Aug 2, 2011 at 3:48
  • I did, and I didn't find anything that seemed to fit the answer... Commented Aug 2, 2011 at 3:55
  • 2
    You are looking for the MSSQL INSERT SQL statement. Search for that. If no such documentation exists, I would immediately drop the product. - And here on SO, related is: stackoverflow.com/questions/1543892/… or stackoverflow.com/questions/3498692/insert-php-sql-server Commented Aug 2, 2011 at 4:02

1 Answer 1

1

There are many php frameworks that are available for you to develop your system. I have used cakephp which helps you to do database quires easily. Why not you look at such frameworks?

The syntax should be something like this:

<?php $in_sql= "INSERT INTO DATA Values(" .$VariableA.",".$VariableB ")"; ?>

Hope it helps you.

Sign up to request clarification or add additional context in comments.

1 Comment

Well... Sorry for the super late reply, but yes, that's more or less what I needed... I'll get into frameworks when I fully understand the base code, that way I'll know what the framework is doing when its condensing functions and what not...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.