Jump to content

DB Update page appears blank but it was working... I have no idea why.


fj1200
 Share

Recommended Posts

:-\ I put this in the MS SQL forum without realising.  Probably better here...

 

Anyone got any ideas why this just gives me a blank page?

 

Admittedly I took some of it from an example in a book, but the example worked and when I transfered the function to this is fails but I need to verify that they enter numbers ONLY - knowing the people involved on the client end they'll try it on...

 

It may not b the function at all.  I've checked all me syntax, semicolons, braketing, etc.  All looks fine.  All it needs to do is enter a typed in final count, a timestamp and change a status flag in a SQL Server database.  It did work fine,  but I don't know what stopped it working.

 

<!DOCTYPE HTML PUBLIC "-//W3C//Ddiv id=\"td\"  HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
   <meta content="MSHTML 6.00.2900.2180" name="GENERATOR">
   

    <head><link rel="stylesheet" href="http://mrserver/css/mr.css" type="text/css" media="screen">
   <META HTTP-EQUIV="Refresh" Content="30;URL=http://mrserver/mr/mr_status.php">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Status v1 - End Job</title>
    </head>
   <body>
      <?php

                    //Validate count to numbers only and max of 6 digits
                        function validateCount($count)
                        {
                            $regexp='/^([0-9]){1,6}$/';

                            if (eregi($regexp,$count)) return 1;
                                else return 0;
                        }

                     //Check form has been submitted...

                        if (isset($_POST['submit']))
                            {
                            $count=htmlentities($_POST['count']);
                            
                            if(validateCount($count))
                               // printf("%s ok", $count);

                        //Split POSTed job data into component parts
                            $job_end = explode("+", $_REQUEST[change_status]);

         //UPDATES Start data after theyhave ended the job
            $con2 = mssql_connect('dbserver', 'UID', 'PWD');
            if (!$con2 || !mssql_select_db('DB', $con2))
            {
                die('**** Unable to connect or select database! ****');
            }
               mssql_query("UPDATE JOB_MR 
                                             SET STATUS = '2', MR_END = GETDATE(), MR_COUNT = '$count'
                                             WHERE ID='$job_end[5]'",$con2)or die;
            mssql_close($con2);
                             else
                                printf("%s invalid", $count);
                            }
      ?>
<div style="font: 16px Verdana;" id="header">End Running Job</div><br>
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
            <input type="text" id="count" name="count" maxlength="6">
            <input type="submit" name="submit" id="submit" value="Submit Final Count">
        </form>
   </body>
</html>

 

As a seperate question - what's the best IDE for PHP?  For the last 2 years I've used Notepad++ and I really like it, and am very comfortable with it but I've started using NetBeans and Eclipse - really so I don't get dependant on one system and also to see what else is available.  Sadly - it needs to be a freebe as the company won't buy anything like this.

Link to comment
Share on other sites

I think mssql_connect is a valid function to connect to a MsSQL server?

 

Change "or die;" to "or die(mysql_error());" and post the error message that is displayed.

 

Notepad++ is great! I'll leave the IDE comparison to someone else as I haven't tried NetBeans.

Link to comment
Share on other sites

mssql_connect() is ok and not the issue since (as I've said) I'm connecting to SQL Server 2000 and not MySQL in this instance  (http://uk2.php.net/manual/en/function.mssql-connect.php).

 

The database connection was working fine - all I've done is to add the validation to an existing and working page.

 

I'll see if I can get the errors but not convinced that's the problem.

 

[edit]

Nope - no errors generated.

[/edit]

Link to comment
Share on other sites

I think I aught to clarify a bit - when the user clicks a button on the main overview page to end the job, this page is opened with a text field to insert the final count.  They then enter said final count and submit, which THEN updates the database. 

 

The problem I'm having is that when the user clicks the button on the main page, this page opens up but is blank.  So it hasn't even attempted the db connection at that time - it's something in the code itself and I can't see it.  Might just be a rogue ';' or " or something else but I can't find it.

Link to comment
Share on other sites

You really should turn error reporting on to help with debugging during the development stage.

 

You are missing curly brackets after the line "if(validateCount($count))". I believe it should start after that line and end just before the else statement.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.