Jump to content

Array help


CageyJ0nnY

Recommended Posts

I have created an array to store data extracted from a dedicated database. I cannot get the code to work and keep geeting an error on line 9; however i cannot see what the error is 8-S.

 

Heres the code:

 

<?php

$conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet234345');

mysql_select_db(“jjennings3db”, $conn);

 

$sql = "SELECT * FROM tblProperties WHERE xxx=xxx";

echo "Here are all the properties that match your search:<br>";

 

$result1 = mysql_query($sql, $conn);

while ($array1 = mysql_fetch_array($result1)) {

echo "<p>Property Name: " . $array1[PropertyName] . "<br>";

echo "Location: " . $array1[Location] . "</p>";

}

?>

 

p.s I have changed log on details

 

many thanks

 

Jonny

Link to comment
Share on other sites

You should always check your queries actually execute successfully and return results before trying to use them.

 

$sql = "SELECT * FROM tblProperties WHERE xxx=xxx";
echo "Here are all the properties that match your search:<br>";

if ($result1 = mysql_query($sql, $conn)) {
  if (mysql_num_rows($result1)) {
    while ($array1 = mysql_fetch_array($result1)) {
      echo "<p>Property Name: " . $array1['PropertyName'] . "<br>";
      echo "Location: " . $array1['Location'] . "</p>";
    }
  } else {
    echo "No results found";
  }
} else {
  trigger_error(mysql_error() . "<br />" . $sql);
}

 

Now, what error are you getting?

?>

Link to comment
Share on other sites

I have inserted the new code and connected to the DB. I am getting a new error message:

 

Notice: No database selected

SELECT * FROM tblProperties WHERE xxx=xxx in /home/jjennings3/jjennings3.bimserver2.com/search.php on line 19

 

line 19 is :

 

trigger_error(mysql_error() . "<br />" . $sql);

 

 

I am confused 8-S

 

thanks for the help

Link to comment
Share on other sites

okay, i have sorted some things out but i have a new error message:

 

 

Notice: Unknown column 'xxx' in 'where clause'

SELECT * FROM tblProperties WHERE xxx=xxx in /home/jjennings3/jjennings3.bimserver2.com/search.php on line 18

 

heres how the code looks at the moment:

 

<?php

$conn = mysql_connect('jjennings3db.bimserver2.com', 'jjennings3db', 'bullet3475783');

mysql_select_db('jjennings3db', $conn);

 

$sql = "SELECT * FROM tblProperties WHERE xxx=xxx";

echo "Here are all the properties that match your search:<br>";

 

if ($result1 = mysql_query($sql, $conn)) {

  if (mysql_num_rows($result1)) {

    while ($array1 = mysql_fetch_array($result1)) {

      echo "<p>Property Name: " . $array1['PropertyName'] . "<br>";

      echo "Location: " . $array1['Location'] . "</p>";

    }

  } else {

    echo "No results found";

  }

} else {

  trigger_error(mysql_error() . "<br />" . $sql);

}

 

?>

 

 

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.