If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

PHP script not running

Hello everyone, back to this script you guys helped with earlier. I have everything else working now except for my 'update' page and script. when the user selects a criteria and hits the search button, all works well. The problem, however, is that with ever output record is a 'details' button that when pressed will take them to a page with that specific records details on it and allow them to modify or delete it. When the press the button though, it just takes you back to the same page without any records on it. Any see something wrong with my code or have any ideas?

Now, however, when it does load the modify page im getting a ton of errors including unknown variable errors that should not be. ive spent the last several days going over it and do not see where I am messing up.

The errors showing up are:

Code:

Warning: mysql_query(): [2002] No connection could be made because the target machine actively refused it. (trying to connect via tcp://localhost:3306) in C:\Inetpub\wwwroot\msag\modify2.php on line 5 Warning: mysql_query(): No connection could be made because the target machine actively refused it. in C:\Inetpub\wwwroot\msag\modify2.php on line 5 Warning: mysql_query(): A link to the server could not be established in C:\Inetpub\wwwroot\msag\modify2.php on line 5 Notice: Undefined variable: rs in C:\Inetpub\wwwroot\msag\modify2.php on line 6 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:\Inetpub\wwwroot\msag\modify2.php on line 6 Notice: Undefined variable: _StreetPrefix in C:\Inetpub\wwwroot\msag\modify2.php on line 66 Notice: Undefined variable: _StreeName in C:\Inetpub\wwwroot\msag\modify2.php on line 67 Notice: Undefined variable: _COMMUNITY in C:\Inetpub\wwwroot\msag\modify2.php on line 73 Notice: Undefined variable: _LOWNUMBER in C:\Inetpub\wwwroot\msag\modify2.php on line 74 Notice: Undefined variable: _HighNumber in C:\Inetpub\wwwroot\msag\modify2.php on line 75 Notice: Undefined variable: _EOB in C:\Inetpub\wwwroot\msag\modify2.php on line 76 Notice: Undefined variable: _ESN in C:\Inetpub\wwwroot\msag\modify2.php on line 82 Notice: Undefined variable: _TELCO in C:\Inetpub\wwwroot\msag\modify2.php on line 83 Notice: Undefined variable: _MAP in C:\Inetpub\wwwroot\msag\modify2.php on line 89 Notice: Undefined variable: _DateEntered in C:\Inetpub\wwwroot\msag\modify2.php on line 90 Notice: Undefined variable: _DateModified in C:\Inetpub\wwwroot\msag\modify2.php on line 98

I am sure it has something to do with the fact that I made this code for a MySQL DB, and am now trying to re write it to work with MsSQL instead, but through testing and research, I am not seeing what I need to fix it. Any advice or help is greatly appreciated.

That error is distinct. Check that your credentials supplied are valid (including target and port), and if so ensure that the socket is established on the MySQL server. It sounds like its up and running though, so there are several causes to that. Start by restarting the mysql service and logging in through the command line interface to see if that works.

Well to make the queries work with SQLServer, you need to return it to a non-proprietary version of the SQL code. Remove the backticks. SQLServer uses square brackets. After that's done, you need to use the SQLSRV package (not the MSSQL which isn't available on Windows 5.3+ versions of PHP), not the MySQL package. Better yet, swap it completely to PDO and use a bind, since then you don't need to concern yourself with the escaping of the strings (which you are otherwise needing to deal with).

Quick glance looks mostly alright. Move that entire first block of querying and fetching into the else clause. You can't populate the $_GET['StreetID'] from the form since you don't provide it in the querystring, but you could check for both post and get (or ugh, request) for it. Given the processing doesn't display the info, I'd say just move it. Make sure you check for the existance of the $_GET['StreetID'] before attempting to read it. Change the include to a require.

Okay, I replaced the firt WHILE and fetch section, got rid of backticks, and changed mysql to sqlsrv. Got rid of a few errors, but now im getting a few differernt erros. as for the variable errors, im assuming that will clear up when the errors above it are corrected. As for PDO, I have never touched it before. Would you mind giving an example?

Error recieved:

Code:

Warning: sqlsrv_query() expects at least 2 parameters, 1 given in C:\Inetpub\wwwroot\msag\modify2.php on line 5 Notice: Undefined variable: rs in C:\Inetpub\wwwroot\msag\modify2.php on line 45 Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, null given in C:\Inetpub\wwwroot\msag\modify2.php on line 45 Notice: Undefined variable: _StreetPrefix in C:\Inetpub\wwwroot\msag\modify2.php on line 66 Notice: Undefined variable: _StreeName in C:\Inetpub\wwwroot\msag\modify2.php on line 67 Notice: Undefined variable: _COMMUNITY in C:\Inetpub\wwwroot\msag\modify2.php on line 73 Notice: Undefined variable: _LOWNUMBER in C:\Inetpub\wwwroot\msag\modify2.php on line 74 Notice: Undefined variable: _HighNumber in C:\Inetpub\wwwroot\msag\modify2.php on line 75 Notice: Undefined variable: _EOB in C:\Inetpub\wwwroot\msag\modify2.php on line 76 Notice: Undefined variable: _ESN in C:\Inetpub\wwwroot\msag\modify2.php on line 82 Notice: Undefined variable: _TELCO in C:\Inetpub\wwwroot\msag\modify2.php on line 83 Notice: Undefined variable: _MAP in C:\Inetpub\wwwroot\msag\modify2.php on line 89 Notice: Undefined variable: _DateEntered in C:\Inetpub\wwwroot\msag\modify2.php on line 90 Notice: Undefined variable: _DateModified in C:\Inetpub\wwwroot\msag\modify2.php on line 98

MySQL is pretty much the only db resource that for whatever reason they decided to force a global scope out of. Because of this, the signature usually accepts a connection resource as the last argument and is optional. Every other db library typically requires the use of the connection in scope, and requires it as the first argument (if its procedural). Another reason that PDO is a better alternative.

I don't typically use PDO as I have a custom abstraction layer that isn't limited to just sql. Documentation is fairly straight forward though.

I added the $conn variable to the first sqsrv query and it cleared that error. I decided to print oujt the errors a little different and this is what I came up with:
[CODE]Notice: Undefined variable: rs in C:\Inetpub\wwwroot\msag\modify2.php on line 53 Warning: sqlsrv_fetch_array(): supplied resource is not a valid ss_sqlsrv_stmt resource in C:\Inetpub\wwwroot\msag\modify2.php on line 53 Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -14

You don't have an $rs variable. You do have an $_rs variable which is likely what you want to use.
Careful not to use the die within the while loop condition. It will assign until it hits a false condition, in which case the die will trigger even during a proper iteration. So you'll want to make sure it is removed completely.

That cleared up all the errors on the screen, however, it is not displaying any of the information at all. On my view all page, I click the details button beside the record, and it should open this page with the records details in it for me to view, modify, or delete. In the URL bar it does show the correct path (msag/modify2.php?StreetID=249) but no information. and if I hit the edit key anyways, it throws that same bunch of unidentified variable errors as before.