PHP/Database issue

Posted on 16th Feb 2014 by admin

My friend is helping me make a database where you go to a certain webpage of my site and the page will use code to pull information from a database and display it on the page in a formatted way.

Code: [Select]<?
function parse($content){
$string = $content;
/* Use <b> to split the string */
$tok = strtok($string, "<b>");

while ($tok !== false) {

$get = "SELECT Name FROM * WHERE Name = '$tok'";
$getsql = mysql_query($get);
if (!$getsql)
{
$type ="";
}
else {
$table = mysql_field_table($getsql);
$type = $table;
}
if (!$type){
$link = $tok;
}
elseif ($type == "quest"){
$link = "<a href='viewlocation.php?location_name=$tok'>$tok</a>";
}
elseif ($type == "item"){
$link = "<a href='viewlocation.php?location_name=$tok'>$tok</a>";
}
else {
$link = $tok;
}

echo $link;
$tok = strtok("</b>");
}}
?>
My friend explains the issue as follows:

QuoteBasically the script uses the tok to split the string up, then im trying to get it to check the whole database name fields for the split.
Then if it finds it, its supposed to get the table name its in and passes it to the if statement.

It splits the string into sections then searches the database for the sections by looking in a specific field over all tables

Then when its found it takes the table it found it in and get the name of the table which gets passed to the if statement which decides which link it will give to the end of the code which gets returned.
But its not doing the search in the database properly and not getting the table name to pass to the if statement to work out the link to give it.

Other forums