![]() |
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?
Main Page: PHP Code:
PHP Code:
|
This line doesn't look right:
<td><a href=\"modify2.php?StreetID=".$result['StreetID']."\"><input type=\"submit\" name = \"details\" value = \"Details\" /></a></td> I wonder if the submit button totally ignores the <a href>. Don't make that modify section of your script a <form>. Remove the <form> line and remove the submit button. Put a graphic image in it's place ... <td><a href=\"modify2.php?StreetID=".$result['StreetID']."\"><img src=\"modbutton.png\" /></a></td> |
Quote:
But, if you fancy using a form, put the modify2.php?StreetID=".$result['StreetID']." as form action instead of the empty string which is there now. |
If you make it a form action,
use <input type=\"hidden\" name=\"StreetID\" value=\".$result['StreetID'].\"> to POST the value. |
Not only that, but what actually happens here?
PHP Code:
PHP Code:
|
Changinh the modify button to an image did the trick to getting the modify page to load on submit:
PHP Code:
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 98PHP Code:
|
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 98New Script: PHP Code:
|
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. PHP Code:
Also, all of this logic needs to move to the else: PHP Code:
|
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 Code:
=> -14 [2] => An invalid parameter was passed to sqlsrv_fetch_array. [message] => An invalid parameter was passed to sqlsrv_fetch_array. ) )PHP Code:
|
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. |
alright, making good progress now, Im down to only one error:
Code:
Warning: sqlsrv_fetch_array() expects parameter 2 to be long, resource given in C:\Inetpub\wwwroot\msag\modify2.php on line 53PHP Code:
|
Sorry fetching doesn't require a resource. Its packed as a part of the statement. Just give it the $_rs. The second parameter would indicate what kind of fetch it performs.
|
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.
see anything outright that could be causing this problem? PHP Code:
|
Remove the semi-colon from the end of the while loop.
Although if you are only expecting one record (as this indicates), then don't loop it at all. |
| All times are GMT +1. The time now is 05:12 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.