Jump to content

Problems with MySQL and PHP


tigomark

Recommended Posts

Hello,

 

I am trying to pull info from a MySQL dbase with a simple script that recieves info from a get request such as

 

http://mysite/subfolder/index.php?where=Alaska

 

The code for the request is as follows

 

 

 

 

include "../includes/prefs.php";

 

 

 

$db_name = "weekends";

 

$table_name = "weekends";

 

$connection = @mysql_connect("$host", "$root", "$password") or

die("Couldn't connect.");

 

$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");

 

$sql = "SELECT *

  FROM $table_name

  WHERE State = \"$where\" 

  ORDER BY WeekendDate

 

 

 

";

 

  $result = @mysql_query($sql,$connection) or die("Couldn't execute query.");

 

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

 

 

$id = $row ['id'];

$State = $row ['State'];

$CityName = $row ['CityName'];

$WeekendDate = $row ['WeekendDate'];

$Email = $row ['Email'];

$Phone = $row ['Phone'];

$HostCouple = $row ['HostCouple'];

 

 

 

 

$weekend_list .="

 

 

<tr>

<td align=\"center\"  valign=\"top\">$CityName</td>

<td align=\"center\"  valign=\"top\">$WeekendDate</td>

<td align=\"center\"  valign=\"top\">$Email</td>

<td align=\"right\"  valign=\"top\">$Phone</td>

<td align=\"center\"  valign=\"top\"><a href=\"/echopay/index.php?State=$where&id=$id\">Sign up Here</a></td>

 

</tr>

 

 

";

 

}

 

 

//HTMl Output would then be in the section below

 

 

 

<div id="you">

<table width="100%" cellpadding="2" cellspacing="2" border="0" align="center">

<tr>

<td align="center" colspan="4"><h2><? echo "$State"; ?></h2></td>

</tr>

<tr>

<th align="center"  valign="top">Location</th>

<th align="center"  valign="top">Encounter Weekend Date</th>

<th align="center"  valign="top">Email</th>

<th align="center"  valign="top">Phone Number</th>

<th align="center"  valign="top"> </th>

</tr>

<? echo "$weekend_list"; ?>

</table>

</div>

 

 

When I test this on my test site and personal site I get the desired output for every state. When I put it to the clients server all that I see is the HTML which is just the Header information. I have never run into this and wanted to see if any one else has run into this.

Link to comment
Share on other sites

1.  Does client have PHP installed?

2.  Does client have MySQL installed?

3.  Does client have MySQL user/password correctly set up for this script?

4.  Is the database (with data) installed on the client's site?

5.  Are you getting any errors on any of the mysql_* function calls?  Check for them via mysql_errno/mysql_error.

Link to comment
Share on other sites

/agree with above post

 

If the only thing that changed is the platform, you gotta check what else is going on!

 

Also,

 

You can replace this:

      $id = $row ['id'];
      $State = $row ['State'];
      $CityName = $row ['CityName'];
      $WeekendDate = $row ['WeekendDate'];
      $Email = $row ['Email'];
      $Phone = $row ['Phone'];
      $HostCouple = $row ['HostCouple'];

 

With this:

@extract($row);

 

http://www.php.net/extract

Link to comment
Share on other sites

Oh, I just noticed another thing in your code.  You should be using full PHP tags (<?php  ?>) instead of the short ones (<? ?>).  If the client's PHP installation is not set to recognize the shorties, then there's a good chance $weekend_list isn't getting echoed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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