1

I'm fairly new to PHP, but here is my issue, I am trying to get the results from a SQL query to display on the page, but I'm not getting anything returned.

Here is the code that I'm currently working with:

    <?php

$con = mysqli_connect("localhost","user","password","database");
if (mysqli_connect_errno()) {
    echo "Connect failed: ". mysqli_connect_error();
}

$de= $con->real_escape_string($_GET["decode"]);

$sql = "select * from FG99_URL where short='".$de."'";
$result = mysqli_query($con, $sql);

while($row = mysqli_fetch_assoc($result)) {
        echo "url: " . $row["url"]. " - fb_url: " . $row["fb_url"]."<br>";

$url=$row['url'];
$fb_url=$row['fb_url'];
$fb_type=$row['fb_type'];
$fb_title=$row['fb_title'];
$fb_description=$row['fb_description'];
$fb_image=$row['fb_image'];
$petpro=$row['petpro'];

echo $fb_url.'test 1</br>';
echo $row['fb_url'] . "test 2</br>";

print $fb_url."test 3</br>";
print $row['fb_url']."test 4</br>";

   }
?>

<head>...

This is what I get returned:

url: - fb_url: 
test 1
test 2
test 3
test 4

Any help would be appriciated.

1
  • debug line by line Commented Sep 26, 2017 at 5:40

2 Answers 2

1

Do a var_dump($row) and see what is in the row variable.

That will help to see whether you have those data in those returning data set.

Based on the output, you are getting some data and returning data might not have the columns you are looking for.

Hope it helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the response. Turns out that all of my columns are capitalized (url -> URL, fb_url -> FB_URL, etc)
0

Check your database first.

After set sql query, try this code:

$sql = "select * from FG99_URL where short='".$de."'";

echo $sql;

Copy and paste sql query into DB client like mysqladmin.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.