Page not working on internal server

I created a few pages on an external server and got everything working great. I copied the files to our internal server at work and I can view records, but nothing updates.

What do I look at for what is different between the servers?

Outside server is UNIX Socket server version 5.5.37-35.1 with MySQL version 5.0.96
•cpsrvd 11.42.1.24
•MySQL client version: 5.0.96
•PHP extension: mysqli Documentation
phpMyAdmin is 3.4.11.1

Internal server is Localhost via TCP/IP
•Microsoft-IIS/8.5
•Database client version: libmysql - mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $
•PHP extension: mysql Documentation

phpMyAdmin version is 4.1.12
BHUCAsked:
Who is Participating?
 
GaryConnect With a Mentor Commented:
Replace all instances of $link with $dbhandle
0
 
GaryCommented:
What do I look at for what is different between the servers?
Apart from the pink elephant in the room that is telling you one is Linux and one is Windows?
0
 
BHUCAuthor Commented:
Gary, so sorry. I know nothing about configuration of servers. First time I have ever worked on an internal server. is there different code I need to do for the update part? If so - can you direct me to a place that I can learn the difference?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
GaryCommented:
What is the php version on the two servers?
Have you get error reporting turned on - this will likely tell you the problem
Both servers can operate exactly the same in an indentical setup but cannot really tell you anything without seeing the code and/or knowing what the error is.
0
 
BHUCAuthor Commented:
On the internal server, it won't show what variables are already in the database and it won't update the database on submit. The code is here:

error shows
Notice: Undefined variable: Submit in C:\inetpub\RCCInfo\update_multiple.php on line 70 which is the if ($Submit) line at the end... I'll start reading..

<?php

$host = "localhost";
$username = "***********";
$password = "*************";
$db_name="test"; // Database name 
 $tbl_name="test_mysql"; // Table name 

// Connect to server and select databse.
 mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
 mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";
 $result=mysql_query($sql);

// Count table rows 
 $count=mysql_num_rows($result);
ini_set('display_errors',1); 
 error_reporting(E_ALL);
 ?>

<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
 <tr> 
 <td>
 <table width="500" border="0" cellspacing="1" cellpadding="0">

 <tr>
 <td align="center"><strong>id</strong></td>
 <td align="center"><strong>Name</strong></td>
 <td align="center"><strong>Lastname</strong></td>
 <td align="center"><strong>Email</strong></td>
 </tr>

<?php
 while($rows=mysql_fetch_array($result)){
 ?>

<tr>
 <td align="center">
<? $id[]=$rows['id']; ?><? echo $rows['id']; ?>
</td>
<td align="center">
<input name="name[]" type="text" id="name" value="<? echo $rows['name']; ?>">
 </td>
<td align="center">
<input name="lastname[]" type="text" id="lastname" value="<? echo $rows['lastname']; ?>">
 </td>
<td align="center">
<input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>">
 </td>
</tr>

<?php
 }
 ?>

<tr>
 <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
 </tr>
 </table>
 </td>
 </tr>
</form>
 </table>

<?php

// Check if button name "Submit" is active, do this 
 if($Submit){
 for($i=0;$i<$count;$i++){
 $sql1="UPDATE $tbl_name SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id='$id[$i]'";
 $result1=mysql_query($sql1);
 }
 }
 mysql_close();
 ?>

Open in new window

0
 
GaryCommented:
Well from that code $Submit does not exist anywhere except where you are checking it and there are no includes in the page.
Are you trying to check if the page was posted?

p.s.
Use the code tags in the future when you are posting code.
0
 
BHUCAuthor Commented:
Yes  - I am trying to learn how to update multiple rows of the same database with one submit button and found this code as a tutorial. I copied and pasted over onto the external server and it worked great, so moved it to the internal.
0
 
GaryCommented:
I don't know how it can work on the external server without some other code there.
At the very least I would expect

if($Submit){

to be
if(isset($_POST['submit'])){
0
 
BHUCAuthor Commented:
That got rid of the submit error but it still isn't submitting.

attached is a screenshot of what it looks like on the internal server vs external

Values aren't pulling in
screenshot.jpg
0
 
GaryCommented:
Have you actually installed PHP on IIS - looks like you haven't - refer the pink elephant in the room.

http://php.iis.net/
0
 
GaryCommented:
Do you use IIS for anything else?
If not It may be beneficial to use XAMPP so you can get an environment as close to the Linux server as possible
0
 
BHUCAuthor Commented:
I added this to the top of the page on the internal server and all information displays:

<?PHP

$dept_query = "SELECT * FROM $tbl_name ";

$dept_query_result = mysql_query($dept_query);
while ($dept_row = mysql_fetch_assoc($dept_query_result))
{
$firstname = $dept_row['name'];
$lastname = $dept_row['lastname'];


echo "$firstname $lastname<br />\n";            
      
}

?>
0
 
GaryCommented:
Ah ha - looking thru your code again
PHP short open tags is not enabled on your local php installation so
<?
will not work
You need to use
<?php

Or enable it in php.ini
short_open_tag=On
0
 
BHUCAuthor Commented:
One more step done - the information now shows up in the fields to edit, but submit doesn't save the changes.
0
 
GaryCommented:
Something is missing because this
 if($Submit){
 for($i=0;$i<$count;$i++){
 $sql1="UPDATE $tbl_name SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id='$id[$i]'";
 $result1=mysql_query($sql1);
 }
 }

Open in new window

...has no relation to anything else in the code you posted, where is
$name[$i]
...coming from?
0
 
GaryCommented:
What is the link to the tutorial you followed?
0
 
BHUCAuthor Commented:
I got it from another expert-exchange thread.

The link is here..  http://www.phpeasystep.com/mysql/10.html

If there is another way I should be learning - please let me know.
0
 
GaryCommented:
phpeasystep.com my arse - how can a (supposedly tutorial) website do something so wrong.
That site is so bad!
Error reporting should be the first line, what's the point of it being halfway down the page lol

This is an example Form - but you should not be using the old MySQL extension for DB queries
It's untested so there maybe some syntax errors

<?php
ini_set('display_errors',1); 
error_reporting(E_ALL);

$host = "localhost";
$username = "***********";
$password = "*************";
$db_name="test"; // Database name 
 $tbl_name="test_mysql"; // Table name 

// Connect to server and select databse.
 mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
 mysql_select_db("$db_name")or die("cannot select DB");


if(isset($_POST['submit'])){
	$name=$_POST['name'];
	$lastname=$_POST['lastname'];
	$email=$_POST['email'];
	$id=$_POST['id'];

	foreach($name as $key => $value) {
		$sql1="UPDATE $tbl_name SET name='$name[$key]', lastname='$lastname[$key]', email='$email[$key]' WHERE id='$id[$key]'";
		$result1=mysql_query($sql1);
	}
}



$sql="SELECT * FROM $tbl_name";
 $result=mysql_query($sql);

// Count table rows 
 $count=mysql_num_rows($result);

 ?>

<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
 <tr> 
 <td>
 <table width="500" border="0" cellspacing="1" cellpadding="0">

 <tr>
 <td align="center"><strong>id</strong></td>
 <td align="center"><strong>Name</strong></td>
 <td align="center"><strong>Lastname</strong></td>
 <td align="center"><strong>Email</strong></td>
 </tr>

<?php
 while($rows=mysql_fetch_array($result)){
 ?>

<tr>
 <td align="center">
<input type="text" name="id[]" value="<?=$rows['id']; ?>">
</td>
<td align="center">
<input name="name[]" type="text" id="name" value="<? echo $rows['name']; ?>">
 </td>
<td align="center">
<input name="lastname[]" type="text" id="lastname" value="<? echo $rows['lastname']; ?>">
 </td>
<td align="center">
<input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>">
 </td>
</tr>

<?php
 }
 ?>

<tr>
 <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
 </tr>
 </table>
 </td>
 </tr>
</form>
 </table>

Open in new window

0
 
BHUCAuthor Commented:
I get this error and it still doesn't update:

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\inetpub\RCCInfo\update_multiple.php
0
 
GaryCommented:
Thats just a warning - did you put your username/password back in?
0
 
BHUCAuthor Commented:
Yes - the data pulls in, but it won't update.
0
 
BHUCAuthor Commented:
Gary or ANYONE who can help.

I changed it to just a basic update script with one field.

This works:
$sql = "UPDATE providers SET ImageFileName='$Image1' WHERE ID='$event_id'";
                                                                $update_result = mysql_query($sql);

This script clears the column in the database
$sql = "UPDATE providers SET FName='$FName' WHERE ID='$event_id'";
                        $update_result = mysql_query($sql);

But this doesn’t on the same page
$sql = "UPDATE providers SET Haines='$Haines' WHERE ID='$event_id'";
                                                                $update_result = mysql_query($sql);

Image is an upload file, name is a text field and Haines is a checkbox


Here are the variables:
 $FName = $_POST['FName'];
 $FName = mysql_real_escape_string($FName, $link);

$Haines = $_POST['Haines'];
$Haines = mysql_real_escape_string($Haines, $link);

            $Image1 = '';

            if (isset($_FILES['image1']))
            {
                  $imagename = basename($_FILES['image1']['name']);
                  if (!(empty($imagename)))
                  {
                        $newimage = "providers/" . $imagename;



                        $result = @move_uploaded_file($_FILES['image1']['tmp_name'], $newimage);

            $Image1 = $imagename;
                  }
            }

Can anyone help me with what I am missing?
0
 
GaryCommented:
After this line
$sql = "UPDATE providers SET Haines='$Haines' WHERE ID='$event_id'";

add
echo $sql

and post the result here
0
 
BHUCAuthor Commented:
Nothing posts...

I have it like this:

$sql = "UPDATE providers SET Haines='$Haines' WHERE ID='$$event_id'";
                        $update_result = mysql_query($sql);
                        echo $sql;
0
 
GaryCommented:
Hold on a minute, this is nothing like your original question.
Post your whole code as you have it now.
0
 
BHUCAuthor Commented:
Thanks Gary.. I'll get that. It is the same issue as the form isn't updating.  It's just a smaller form that I was stuck on before and remembered that the photo updated, but nothing else would.

Let me get rid of all the extra stuff and I'll upload the file. If I should open another question, let me know, but the original question still hasn't been solved.
0
 
GaryCommented:
Just post your real code, no need for a new question.
0
 
BHUCAuthor Commented:
Here is the file... insert and update don't work.  I commented out the main update code to work with just the smaller one that works for an image, but not the others.
edit-nurses.php
0
 
GaryCommented:
Can you do a dump of your providers table and attach it here
0
 
BHUCAuthor Commented:
0
 
BHUCAuthor Commented:
OMG - that worked.... now can you explain why I need to do that? is it a windows thing?

I am heading back to PHP school to learn all the new stuff. I can't thank you enough.
0
 
GaryCommented:
No, you were referencing a db connection ($link) that didn't exist - your connection is called $dbhandle
0
All Courses

From novice to tech pro — start learning today.