Jump to content

simple while loops doesnt work on new server


sherm

Recommended Posts

i have a php file that works perfectly with my hosting. however, the file now needs to be transferred to my boss's host.  I transfered the file and now it doesnt work.  My server is running php 4.4 and his is running 4.3.

 

Here is the part of the script that I can't figure out how to fix:

 

while($row = mysql_fetch_array($result))
  {
if ($row['status'] == 'complete') {
	echo('You have already taken the survey');
}
  }

 

Basically, this checks to see if the user has completed the survey.  If they have, it echos an error message.  However, on the new server it doesn't seem to check the status.

 

Any ideas why?

The definition in programming of assume is: "To make an ass out of u and me"

 

It is likely that your code has no error checking, error reporting, and error recovery logic in it to get it to tell you if it did not work, what was wrong, and to prevent any following code from blindly using a nonexistent result.

 

You would need to post your code to get any specific help with it.

<?php
$con = mysql_connect("xxxx", "xxxxx", "xxxxxxx");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("jlenze", $con);

mysql_query("INSERT INTO resident_name (name, status) VALUES ('$name', 'incomplete')", $con);



$searchtable = "SELECT name, status FROM resident_name WHERE name='$name'";
$result = mysql_query($searchtable);




while($row = mysql_fetch_array($result))
  {

if ($row['status'] == 'complete') {
	echo('You have already taken the survey');
}

  }

mysql_close($con);
?>

I'm new to php coding... So I don't really know how to do proper error checks.

 

Also, if it helps:  the $name variable is pulled from an url that is loaded from a remote program... basically, the program sends an http request to "mysite.com/connect.php?name=John Doe"  ... then the php file pulls the name and adds it to the database unless they have already completed the survey

Archived

This topic is now archived and is closed to further replies.

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