Jump to content

Simple Error


Ducky1

Recommended Posts

Hi Guys,

Trying to do a really simple script. Not sure, but i think the error is getting the user / $table variable into the query. Thanks in advance.

 

<?php
$table = $_GET['user'];
$conn = mysql_connect("**", "***", "***");
if (!$conn ) 
{ 
echo "Could not connect to the database."; 
}
$did_we_find_a_db_to_use = mysql_select_db("rovstr_peter");
if (!$did_we_find_a_db_to_use) 
{ 
echo "Invalid database name."; 
}
$data = mysql_query("SELECT * FROM rank WHERE name = '$table'");
Print "<table border cellpadding=3>";
$info = mysql_fetch_array($data);
while($info = mysql_fetch_array($data))
{
echo "test";
Print "<tr>";
Print "<th>Name:</th> <td>".$info['name'] . "</td> ";
Print "<th>Rank:</th> <td>".$info['rank'] . " </td>";
Print "<th>Title:</th> <td>".$info['title'] . "</td> ";
}
Print "</table>";
echo("End");
?>

Link to comment
https://forums.phpfreaks.com/topic/162112-simple-error/
Share on other sites

Just realised that after posting, but changed the password for it already just in case :D

 

Its just that the

$data = mysql_query("SELECT * FROM rank WHERE name = '$table'");

- getting the $table into the query, and where it says echo "test", it never appears, so it must be failing somewhere

Link to comment
https://forums.phpfreaks.com/topic/162112-simple-error/#findComment-855467
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.