Current location: Hot Scripts Forums » Programming Languages » PHP » Probs when transferring script over to Live Server


Probs when transferring script over to Live Server

Reply
  #1 (permalink)  
Old 08-02-10, 07:49 AM
WillUK WillUK is offline
Wannabe Coder
 
Join Date: Jan 2009
Location: Beverley, England
Posts: 130
Thanks: 5
Thanked 2 Times in 1 Post
Probs when transferring script over to Live Server

Hi

I have recently built a newsletter that enables the administrator to select which members/users should receive the newletter - depending on particular criteria.

I have tested this on my local Apache server and it works without a problem.

However, after I have transferred over to our host: datagate, The script will not function at all.

I have tested the code with the usual sql echo line - to check that the email addresses are being pulled from the relevant table. Again, on my local server they are. But on the live server they are not...

I am using the Windows Platform (Windows Vista), but our live host uses Unix.

I am using MySQL version 5.1.33
Apache version: 2.2.11
PHP version: 5.2.9-2

I have noticed that when I echo the email values on my localhost, the values returned have no spaces seperating them i.e the returned values look like:
'user1@mysite.comuser2@mysite.comuser3@mysite.com' etc etc
This may be posing problems. I'm not sure - but can't think of what else the problem could be...

I've attached the script below.

HTML Code:
 <div class='column_main'>
<form enctype="multipart/form-data" action="<?php //echo //$_SERVER[" "];?>" method="post">
<table width="400"  border="0" cellspacing="0" cellpadding="2"> 
<tr> 
<td><h1>Which business categories do you wish to send this newsletter to?</h1></td>
</tr>
<tr>
<td><label>LTD companies</label></td>                  <td><input type="radio" name="bus_status" value="LTD" /></td>
<td><label>Sole traders &amp; Partnerships</label></td><td><input type="radio" name="bus_status" value="ST/PSHP" /></td>
<td><label>PLCs</label></td>                           <td><input type="radio" name="bus_status" value="PLC" /></td>  
<td><label>All types</label></td>                      <td><input type="radio" name="bus_status" value="all" /></td>
</tr>
<tr>
<td><h1>Which industry types do you wish to include in this newsletter?</h1></td>
<td><select name="industry"><option>Select industry</option>
PHP Code:

 // Retrieve all the industries and add to the pull-down menu.
$query "SELECT ind_id, ind_name FROM industry ORDER BY ind_id";        
$result = @mysql_query ($query);
while (
$row mysql_fetch_array ($resultMYSQL_BOTH)) {
    echo 
"<option  value='" $row['ind_id'] . "' > {$row['ind_name']}<option>\n";    

HTML Code:
<tr>
<td><h2><label>Message:</label></h2></td> 
<td><textarea name ="message" cols="70" rows="10"></textarea></td>    
</tr>         
<tr>
<td><input type="submit" name="submit" value="send" /></td>
</tr>
</select>
</table>
</form>
</div>
PHP Code:

} else {    
            if (
$_POST['bus_status'] == 'LTD'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'LTD', ind_id = '$industry'";
            
$result = @mysql_query ($query);
            } else if (
$_POST['bus_status'] == 'ST/PSHP'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'ST/PSHP', ind_id = '$industry'";
            
$result = @mysql_query ($query);  
            } else if (
$_POST['bus_status'] == 'PLC'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'PLC', ind_id = '$industry'";
            
$result = @mysql_query ($query);  
            } else if (
$_POST['bus_status'] == 'all'){  
            
$query "SELECT email FROM at_client_profile WHERE ind_id = '$industry'";
           
$result = @mysql_query ($query);  
           } else {
           echo 
"<h1>There was an error completing the form. Please check and try again.</h1>";
           }
           
             
$subject "Newsletter";
             
$message "Message: ".$_POST['message']."\n";
             
$mailheaders ="From: Mysite <noreply@mysite.com> \n";
             while (
$row mysql_fetch_array($resultMYSQL_BOTH)) {
             
//echo $row['email'];
             
date_default_timezone_set('UTC');
             
mail($row['email'],$subject,$message,$mailheaders);
             }
             echo 
"<div class='column_main'><h3>The Newsletter Has Been Sent</h3></div>";
       }
    
        
mysql_close(); // Close the database connection. 
Sorry for the long lines of code, but thought it best to provide as much of the data as might be useful....
On the live server, the output on screen is "The Newsletter Has Been Sent". However, as previosuly stated: I've echoed the previous sql call (echo $row['email'], and no lines are being returned....

Any ideas what the problem might be??

Thanks

Last edited by WillUK; 08-02-10 at 07:52 AM.
Reply With Quote
  #2 (permalink)  
Old 08-03-10, 07:56 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
In these queries you are using a comma to separate the conditions in the WHERE clause.
PHP Code:

if ($_POST['bus_status'] == 'LTD'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'LTD', ind_id = '$industry'";
            
$result = @mysql_query ($query);
            } else if (
$_POST['bus_status'] == 'ST/PSHP'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'ST/PSHP', ind_id = '$industry'";
            
$result = @mysql_query ($query);  
            } else if (
$_POST['bus_status'] == 'PLC'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'PLC', ind_id = '$industry'";
            
$result = @mysql_query ($query);  
            } else if (
$_POST['bus_status'] == 'all'){  
            
$query "SELECT email FROM at_client_profile WHERE ind_id = '$industry'";
           
$result = @mysql_query ($query); 
Instead use AND.
PHP Code:

if ($_POST['bus_status'] == 'LTD'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'LTD' AND ind_id = '$industry'";
            
$result = @mysql_query ($query);
            } else if (
$_POST['bus_status'] == 'ST/PSHP'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'ST/PSHP' AND ind_id = '$industry'";
            
$result = @mysql_query ($query);  
            } else if (
$_POST['bus_status'] == 'PLC'){
            
$query "SELECT email FROM at_client_profile WHERE status = 'PLC' AND ind_id = '$industry'";
            
$result = @mysql_query ($query);  
            } else if (
$_POST['bus_status'] == 'all'){  
            
$query "SELECT email FROM at_client_profile WHERE ind_id = '$industry'";
           
$result = @mysql_query ($query); 
Also check and make sure $industry has a value.
__________________
Jerry Broughton
Reply With Quote
  #3 (permalink)  
Old 08-03-10, 03:29 PM
WillUK WillUK is offline
Wannabe Coder
 
Join Date: Jan 2009
Location: Beverley, England
Posts: 130
Thanks: 5
Thanked 2 Times in 1 Post
thanks

Cheers Jerry
I have to assume that $industry does have a value because the application is working on my localhost....
The SQL syntax was going to be my next point of investigation!

Thanks gain....I'll see if it works!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 6 03-16-09 07:15 AM
Script won't always run on server patter PHP 2 08-19-07 02:34 PM
Submit button....can it send info to my email w/out the use of php???? lisa33 HTML/XHTML/XML 7 10-17-06 11:46 AM
Download files from another server using script! benweston Script Requests 5 01-17-06 09:29 AM


All times are GMT -5. The time now is 08:16 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.