Jump to content

stockton

Members
  • Posts

    319
  • Joined

  • Last visited

    Never

Everything posted by stockton

  1. Can one, from php, connect to two databases in the same script. I need to write an application to process and display data from two seperate MSSQL databases both on the same server. If I write the two routines(scripts) seperately and run them as such they both work but when I put them together in one script the second one is failing?
  2. Am I misunderstanding the PHP Manual, where it says:- mixed *mssql_query* ( string query [, resource link_identifier [, int batch_size]] ) Returns: A MS SQL result resource on success, *TRUE* if no rows were returned, or *FALSE* on error. and my code reads:- $insert = sprintf("INSERT INTO Users (FirstName, LastName, Usrname,Passwrd, AccessLevel, last_login,UserID)                         VALUES ('%s', '%s', '%s', '%s', '%d', '%s', '%d')",                             $FirstName, $Surname, $uname, $passwd,$accesslevel, $regdate, $_SESSION['UID']); $Reply = mssql_query($insert, $link); if ($Reply == FALSE)         { whether the query works or not I have yet to find $Reply equal to FALSE. Please tell me what I am misunderstanding and what is the correct method  ????
  3. You are being a little confusing as apt is Linux specific and to the best of my knowledge MSSQL wont work on Linux. My setup is Ubuntu as the test client and the server has Windows XP, Apache and PHP and I suspect that you may want to do something similar. Do remember that PHP runs on the server not the client and to the best of my knowledge MSSQL has to be on the server.
  4. Do a google for "Online Books at Microsoft".
  5. Do you have a table called wucc_users? Look in SQL Server Enterprise Manager and see what exists within that database where the table wucc_users table should be.
  6. In my code I just altered the mysql_connect to mssql_connect as well as mysql_select_db to mssql_select_db
  7. Using MSSQL database I am attempting to insert a new user into a table using the following command in PHP:- INSERT INTO Users (FirstName, LastName, Usrname, Passwrd, AccessLevel, last_login, UserID) VALUES ('Alf', 'Stockton', 'alf',0xd8cc7e40d17aaefd27cd324f7ba91079, '9', '2006/09/29 12:05:23', '0') However this fails and I am not sure why. BTW The value starting 0xd8....... is the password converted via md5() Please tell me what I got wrong.
  8. The following php fails with:- Warning: ociexecute() [function.ociexecute]: OCIStmtExecute: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'SPMEMBERDETAILS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored in C:\Program Files\Apache Group\Apache2\htdocs\KioskCurrent\GM2.php on line 28 Cannot Execute statement [code]<?php $number = "2100418933"; // Connect to database... $conn=OCILogon("big", "big"); if ( ! $conn ) { echo "Unable to connect: " . var_dump( OCIError() ); die(); } $cursor = OCINewCursor($conn); $stmt = OCIParse($conn, "BEGIN spPackage.spMemberDetails(:number, :cv_memberdetails); END;") or die('Cannot parse query'); OCIBindByName($stmt, ":cv_memberdetails", &$cursor) or die('Cannot bind array variable'); OCIBindByName($stmt, ":number", &$number) or die('Cannot bind number variable'); $exec = OCIExecute($stmt) or die('Cannot Execute statement'); OCIExecute($cursor); while ($data = OCIFetchInto($cursor)) { var_dump($data); } OCIFreeStatement($stmt); OCIFreeCursor($cursor); OCILogoff($conn); ?> and the stored procedure looks like SQL> desc sppackage; PROCEDURE SPGETMEMBERNUMBER Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P_NUMBER VARCHAR2 IN P_MEMBERNUMBER VARCHAR2 OUT PROCEDURE SPGETSLOTSHANDLE Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P_HANDLE NUMBER(15,2) OUT P_NUMBER VARCHAR2 IN P_STARTDATE VARCHAR2 IN P_ENDDATE VARCHAR2 IN PROCEDURE SPGETTABLEHANDLE Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P_HANDLE NUMBER(15,2) OUT P_NUMBER VARCHAR2 IN P_TABLEGAMEPREFIX VARCHAR2 IN P_STARTDATE VARCHAR2 IN P_ENDDATE VARCHAR2 IN PROCEDURE SPMEMBERDETAILS Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P_NUMBER VARCHAR2 IN CV_MEMBERDETAILS REF CURSOR OUT RECORD OUT R_MEM_NUMBER VARCHAR2(12) OUT R_MEM_SNAME VARCHAR2(25) OUT R_MEM_FNAME VARCHAR2(25) OUT R_MEM_TITLE VARCHAR2(25) OUT PROCEDURE SPTABLESPLAYED Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P_NUMBER VARCHAR2 IN P_STARTDATE VARCHAR2 IN P_ENDDATE VARCHAR2 IN CV_TABLESPLAYED REF CURSOR OUT RECORD OUT :[/code] Please tell me what I have done incorrect.
  9. [!--quoteo(post=387421:date=Jun 24 2006, 02:09 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 24 2006, 02:09 PM) [snapback]387421[/snapback][/div][div class=\'quotemain\'][!--quotec--] I have no idea why each element of your form has the same name and the same ID (and ID is most likely redundant), but the reason why the textarea displays nothing is because your coding was incorrect. The below should work. [code]<textarea rows='6' cols='80' name='Message' ID='Message' wrap='physical'> <?php echo $txtMessage; ?></textarea>[/code] [/quote] Thank you. Would you believe I have looked at a missing > for more than a day and never saw it. Thank you again.
  10. Please tell me why the following php code does not work. <form name=Message ID=Message action=messageUpdateProcess.php?UID=<?php echo $intID ?> method=post> Message: <textarea rows=6 cols=80 name=Message ID=Message wrap=physical <?php echo $txtMessage ?></textarea> $txtMessage even though populated with data never appears in the textarea. The previous line <?php echo $intID ?> works fine.
  11. [!--quoteo(post=378687:date=May 31 2006, 02:34 PM:name=Honoré)--][div class=\'quotetop\']QUOTE(Honoré @ May 31 2006, 02:34 PM) [snapback]378687[/snapback][/div][div class=\'quotemain\'][!--quotec--] Maybe this insert statement will solve the problem: [code] $insert = $db_object->prepare("INSERT INTO Users (FirstName, LastName, Usrname, Passwrd, AccessLevel, last_login, U serID) VALUES ('".$_POST['FirstName']."', '".$_POST['Surname']."', '".$_POST['uname']."', '".$_POST['passwd']."', '".$_POST['accesslevel']."', '".$regdate.", 1'"); [/code] [/quote] Thank you. It is always the little things that frustrate one. However I fail to understand the single quote double quote combination. ie What does '" after the 1 mean?
  12. I keep getting the following error in what should be a very simple php/html piece of code:- [error] PHP Parse error: syntax error, unexpected T_STRING in /var/www/htdocs/events/doc/Register.php on line 61 The code is as follows:- <?php // [a href=\"http://www.free2code.net/plugins/articles/read.php?id=99\" target=\"_blank\"]http://www.free2code.net/plugins/articles/read.php?id=99[/a] require('db_connect.php'); // database connect script. ?> <html> <head> <title>Register a User</title> </head> <!--#include virtual="includes/logo.inc"--> <?php if (isset($_POST['submit'])) { // if form has been submitted if (!$_POST['uname'] | !$_POST['passwd'] | !$_POST['passwd_again'] | !$_POST['accesslevel']) { die('You did not fill in a required field.'); } // check if username exists in database. if (!get_magic_quotes_gpc()) { $_POST['uname'] = addslashes($_POST['uname']); } $name_check = $db_object->query("SELECT Usrname FROM Users WHERE Usrname = '".$_POST['uname']."'"); if (DB::isError($name_check)) { $Message = $name_check->getMessage(); trigger_error(E_USER_ERROR, $Message); } $name_checkk = $name_check->numRows(); if ($name_checkk != 0) { $Message = sprintf("Sorry, the username: %s is already taken, please pick another one.", $_POST['uname']); trigger_error(E_USER_ERROR, $Message); } if ($_POST['passwd'] != $_POST['passwd_again']) { $Message = "Passwords did not match."; trigger_error(E_USER_ERROR, $Message); } $_POST['Surname'] = strip_tags($_POST['Surname']); $_POST['FirstName'] = strip_tags($_POST['FirstName']); $_POST['uname'] = strip_tags($_POST['uname']); $_POST['passwd'] = strip_tags($_POST['passwd']); $_POST['accesslevel'] = strip_tags($_POST['accesslevel']); $_POST['passwd'] = md5($_POST['passwd']); if (!get_magic_quotes_gpc()) { $_POST['passwd'] = addslashes($_POST['passwd']); } $regdate = date('Y-m-d H:i:s'); $insert = $db_object->prepare("INSERT INTO Users (FirstName, LastName, Usrname, Passwrd, AccessLevel, last_login, U serID) VALUES ('".$_POST['FirstName']."', '".$_POST['Surname']."', '".$_POST['uname']."', '".$_POST['passwd']."', '".$_POST['accesslevel']."', $regdate., 1)); if (PEAR::isError($insert)) { $Message = $insert->getMessage(); trigger_error(E_USER_ERROR, $Message); } $add_member = $db_object->execute($insert); if (DB::isError($add_member)) { $Message = $add_member->getMessage(); trigger_error(E_USER_ERROR, $Message); } // header("location: index.shtml"); // exit; } else { // if form hasn't been submitted ?> <!--#include virtual="includes/logo.inc"--> <br><br> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table align="center" border="3" cellspacing="0" cellpadding="3"> <tr><td>First Name:</td> <td><input type="text" name="FirstName" maxlength="20"></td></tr> <tr><td>Surname:</td> <td><input type="text" name="Surname" maxlength="40"></td></tr> <tr><td>Username*:</td> <td><input type="text" name="uname" maxlength="40"></td></tr> <tr><td>Password*:</td> <td><input type="password" name="passwd" maxlength="50"></td></tr> <tr><td>Confirm Password*:</td> <td><input type="password" name="passwd_again" maxlength="50"></td></tr> <tr><td>Access Level*:</td> <td><input type="text" name="accesslevel" maxlength="2"></td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Submit"></td></tr> </table> </form> <?php } ?> </body> </html> and line 61 is // header("location: index.shtml"); which one can see is commented out. I actually suspect the problem lies in the sql insert string but I cannot see it. Please help.
  13. I have upgraded my Slackware 10.2 Linux server to php-5.1.4 and now find that since the upgrade I cannot run php programs there. The error message I get is:- >> Server Error >> The following error occurred: >> >> [code=SERVER_RESPONSE_CLOSE] The server closed the connection while reading the response. Contact your system administrator. and in /var/log/apache/error_log I get:- child pid 11681 exit signal Segmentation fault (11) and nothing applicable in /var/log/messages or /var/log/syslog or /var/log/apache/access_log. Apache is still running fine as can be seen by browsing to [a href=\"http://www.stockton.co.za\" target=\"_blank\"]http://www.stockton.co.za[/a] but if one browses to [a href=\"http://www.stockton.co.za/info.php\" target=\"_blank\"]http://www.stockton.co.za/info.php[/a] the aforementioned error should occur. Yes I have restarted Apache after the upgrade to php-5.1.4.
  14. I have a php program that works using includes and functions but I now wish to get it working using Ajax. Is this the correct place to ask Ajax questions ?
  15. I found that using $Datum = date("'Y-m-d H:i:s'"); rather than getdate() worked fine.
  16. Please tell me what is wrong with the following piece of code:- $Datum = date("'Y-m-d H:i:s'"); $link = mssql_connect("localhost", "sa", "") or trigger_error('Could not connect to database', E_USER_ERROR); mssql_select_db("pm", $link) or trigger_error('Could not select database', E_USER_ERROR); $proc = mssql_init("spGetActivePromotions", $link); mssql_bind($proc, "@Today", $Datum, SQLTEXT, FALSE,FALSE,strlen($Datum)); $Result = mssql_execute($proc); if (!$Result) { $Message = sprintf("mssql_execute failed for %s [%d].", $Datum, $Result); trigger_error($Message, E_USER_ERROR); die(); } the stored procedure that I am attempting to use looks like :- CREATE PROCEDURE spGetActivePromotions @Today datetime AS SELECT PromotionID, PromotionName, StartDate, EndDate, LastDrawDate, MaxDraws, NumRegTickets, VouchersPermitted, NumTicketsPerVoucher, ManualTicketIssue FROM Promotion WHERE @Today>=StartDate AND @Today<=EndDate GO
  17. I am attempting using the result of getdate() as a key to a MSSQL database. The MSSQL index is a SQLDATETIME. I use :- $StartDate = getdate(); and after connecting and selecting the database mssql_bind($proc, "@StartDate", $StartDate, SQLDATETIME); This fails. Is there something I need to do to the variable I get from getdate() before making the MSSQL call?
  18. Please tell me how one converts the result from PHP's getdate() function to an SQLDATETIME.
  19. I am failing in an attempt to access an Oracle database using the following php. The calls I have tested are as follows:- $query = "begin spPackage.spMemberDetails(_number,:cv_memberdetails); end;"; $stmt = OCIParse($conn, $query ) or die('Cannot parse query'); OCIBindByName($stmt,"_number",$number, -1) or die('First cannot bind variable'); OCIBindByName($stmt, ":cv_memberdetails", &$array, -1) or die('Second cannot bind variable'); OR $query = "begin spPackage.spMemberDetails(_number); end;"; $stmt = OCIParse($conn, $query ) or die('Cannot parse query'); OCIBindByName($stmt,"_number",$number, -1) or die('First cannot bind variable'); I get the following error message:- ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'SPMEMBERDETAILS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored begin spPackage.spMemberDetails(_number); end; ^ The 1st part of the stored procedure I am trying to use is as follows:- CREATE OR REPLACE PACKAGE "BIG"."SPPACKAGE" AS type memberdetail_type is record ( r_mem_number members.mem_number%type, r_mem_sname members.mem_sname%type, r_mem_fname members.mem_fname%type, r_mem_title members.mem_title%type); type memberdetail_cur_type is ref cursor return memberdetail_type; PROCEDURE spMemberDetails( p_number cards.card_number%type, --varchar2 cv_memberdetails out memberdetail_cur_type); Please tell me what I am not understanding and where I have gone wrong. BTW I did not write the stored procedure.
×
×
  • 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.