Jump to content

Douglas28

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by Douglas28

  1. I've written a simple Poll script which works fine on localhost, and it appears to work on my remote host without errors yet nothing seems to be updated in SQL Server. I'm starting to feel like I'm going crazy with this. My Stored Procedure: USE [FortissimoMedia] GO /****** Object: StoredProcedure [Douglas28].[insertVote] Script Date: 11/26/2011 20:10:06 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [Douglas28].[insertVote] ( @PollID int, @VoteAnswer varchar ) AS IF @VoteAnswer = 'Answer1' UPDATE tblPollVotes SET Answer1 = Answer1 + 1 WHERE PollID = @PollID ELSE IF @VoteAnswer = 'Answer2' UPDATE tblPollVotes SET Answer2 = Answer2 + 1 WHERE PollID = @PollID ELSE IF @VoteAnswer = 'Answer3' UPDATE tblPollVotes SET Answer3 = Answer3 + 1 WHERE PollID = @PollID ELSE IF @VoteAnswer = 'Answer4' UPDATE tblPollVotes SET Answer4 = Answer4 + 1 WHERE PollID = @PollID ELSE IF @VoteAnswer = 'Answer5' UPDATE tblPollVotes SET Answer5 = Answer5 + 1 WHERE PollID = @PollID Relevant PHP code: } elseif (isset($_GET["InsertVote"]) && $_GET["InsertVote"] == "True") { $con = mssql_connect(".\SQLExpress", "username", "password"); mssql_select_db("FortissimoMedia", $con); $stmt = mssql_init("InsertVote", $con); // Bind values mssql_bind($stmt, "@PollID", $_GET["PollID"], SQLINT1, false, false); mssql_bind($stmt, "@VoteAnswer", $_POST["Vote"], SQLVARCHAR, false, false, 8000); mssql_execute($stmt); echo "Thank you, your vote has successfully been added to the database. Click <a href='$_SERVER[sCRIPT_NAME]?ViewResults=True&PollID=$_POST[PollID]'>here</a> to view the results."; } $rs = odbc_exec($con, "SELECT * FROM tblPolls WHERE Active = 'Yes'"); while (odbc_fetch_row($rs)) { echo odbc_result($rs, "PollQuestion"); ?> <br /><br /> <form action="<?php $_SERVER["SCRIPT_NAME"] ?>?InsertVote=True&PollID=<?php echo odbc_result($rs, "PollID") ?>" method="post"> <input type="radio" name="Vote" value="Answer1" /> <?php echo odbc_result($rs, "PollAnswer1"); ?><br /> <input type="radio" name="Vote" value="Answer2" /> <?php echo odbc_result($rs, "PollAnswer2"); ?><br /> <input type="radio" name="Vote" value="Answer3" /> <?php echo odbc_result($rs, "PollAnswer3"); ?><br /> <input type="radio" name="Vote" value="Answer4" /> <?php echo odbc_result($rs, "PollAnswer4"); ?><br /> <input type="radio" name="Vote" value="Answer5" /> <?php echo odbc_result($rs, "PollAnswer5"); ?><br /> <input type="hidden" name="PollID" value="<?php echo odbc_result($rs, "PollID"); ?>" /> <p><input type="submit" value="Submit" /> <a href="<?php $_SERVER["SCRIPT_NAME"] ?>?ViewResults=True&PollID=<?php echo odbc_result($rs, "PollID") ?>">Results</a></p> </form> <?php } Hope someone can offer a suggestion. Thank you Douglas
  2. SQL Server keeps showing my DateTime as in the actual database. I'm baffeled at this. My PHP Cookbook gives me different solutions like localtime() , but nothing seems to work. I use Stored Procedures for SQL Server - as you do. My Stored Procedure is below: USE [FortissimoMedia] GO /****** Object: StoredProcedure [dbo].[insertHome] Script Date: 11/22/2011 23:21:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[insertHome] ( @PostContent TEXT, @PostAuthor TEXT, @DatePosted datetime, @IP TEXT ) AS INSERT INTO tblHome (PostContent, PostAuthor, DatePosted, IP) VALUES (@PostContent, @PostAuthor, @DatePosted, @IP) And my PHP code is below: $con = mssql_connect(".\SQLExpress", "Username", "Password"); // hidden for obvious reasons mssql_select_db("FortissimoMedia", $con); $stmt = mssql_init("InsertHome", $con); mssql_bind($stmt, '@PostContent', $_POST["PostContent"], SQLTEXT, false, false); mssql_bind($stmt, '@PostAuthor', $PostAuthor, SQLTEXT, false, false); mssql_bind($stmt, '@DateAdded', date("Y-m-d", time()), SQLDATETIME, false); mssql_bind($stmt, '@IP', $_SERVER["REMOTE_ADDR"], SQLTEXT, false, false); mssql_execute($stmt); Maybe it's just cause I didn't get enough sleep last night or I might not be doing something right. Hope someone can advise me. Thank you Douglas
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.