Jump to content

[SOLVED] Request Data


Ads

Recommended Posts

A simple example.

 

<?php

  $sql = "SELECT data FROM foo WHERE id = 1 LIMIT 1";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      $row = mysql_fetch_assoc($result);
      echo $row['data'] . "<br />";
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/76034-solved-request-data/#findComment-384901
Share on other sites

A simple example.

 

<?php

  $sql = "SELECT data FROM foo WHERE id = 1 LIMIT 1";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      $row = mysql_fetch_assoc($result);
      echo $row['data'] . "<br />";
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }

?>

 

Query failed

Unknown column 'data' in 'field list'

SELECT data FROM players WHERE id = 1 LIMIT 1

 

Thats the Error :(

 

  $sql = "SELECT data FROM players WHERE id = 1 LIMIT 1";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      $row = mysql_fetch_assoc($result);
      echo $row['username'] . "<br />";
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }

Link to comment
https://forums.phpfreaks.com/topic/76034-solved-request-data/#findComment-384904
Share on other sites

You might want.....

 

<?php

  $sql = "SELECT username FROM players WHERE id = 1 LIMIT 1";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      $row = mysql_fetch_assoc($result);
      echo $row['username'] . "<br />";
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/76034-solved-request-data/#findComment-384906
Share on other sites

This is the New error i get:

Query failed

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

SELECT username FROM players WHERE email =

 

	$email = $_SESSION['email'];
  $sql = "SELECT username FROM players WHERE email = $email";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      $row = mysql_fetch_assoc($result);
      echo $row['username'] . "<br />";
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }

 

 

What i am trying to do is get the Persons Name to Be displayed By Finding there Email.

Link to comment
https://forums.phpfreaks.com/topic/76034-solved-request-data/#findComment-384908
Share on other sites

Cool thanx, BUT, now it says That there are no results found? But there should be.

 

heres the code.

	$email = $_SESSION['email'];
$sql = "SELECT username FROM players WHERE email = '$email'";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      $row = mysql_fetch_assoc($result);
      echo $row['username'] . "<br />";
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }

Link to comment
https://forums.phpfreaks.com/topic/76034-solved-request-data/#findComment-384926
Share on other sites

The results don't lie. Have you got a call to session_start() prior to using the $_SESSION array? Also, try trimming the email of any extra whitespace.

 

<?php

  session_start();
  $email = trim($_SESSION['email']);
  $sql = "SELECT username FROM players WHERE email = '$email'";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      $row = mysql_fetch_assoc($result);
      echo $row['username'] . "<br />";
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />" . mysql_error() . "<br />$sql";
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/76034-solved-request-data/#findComment-384941
Share on other sites

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.