Jump to content

simple t_string error occurance


87dave87

Recommended Posts

$query1 = mysql_query('show tables');

$search_query = "select emulator, version, os, platform, details from "$query1" where emulator LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' OR platform LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' order by platform asc, emulator asc";

 

Im trying to show all tables in 'query1': -

 

Parse error: syntax error, unexpected T_VARIABLE in /home/irrm3a/public_html/search.php on line 5

 

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

you are not giving enough information, but from what i have gathered so far is your search query string.

 

$search_query = "select emulator, version, os, platform, details from '$query1' where emulator LIKE %'".mysql_real_escape_string($_POST["emusearch"])."'% OR platform LIKE %'".mysql_real_escape_string($_POST["emusearch"])."'% order by platform asc, emulator asc";

and show tables should be something like this if its a variable

mysql_query($show_tables);

toonmariner ive tried to do that, then i get this error: -

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/irrm3a/public_html/search.php on line 15

 

This is the full code: -

 

<?
include($_SERVER['DOCUMENT_ROOT'] . '/includes/head.php'); 
include($_SERVER['DOCUMENT_ROOT'] . '/includes/dbconnect.php'); 
$query1 = mysql_query('show tables'); 
$search_query = "select emulator, version, os, platform, details from '$query1' where emulator LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' OR platform LIKE '%".mysql_real_escape_string($_POST["emusearch"])."%' order by platform asc, emulator asc"; 

if (empty($_POST['emusearch']))
{
echo "<meta http-equiv='refresh' content='0; URL=/noresults.php'>"; 
exit();
}
else
{
$search = mysql_query($search_query);
$num_rows = mysql_num_rows($search); 

	if($num_rows < 1) 
	{ 
   		echo "<meta http-equiv='refresh' content='0; URL=/noresults.php'>"; 
	exit();
	}
}
?>

sorry was looking in the second query string...

 

The ' from $query1 ' will fail because $query1 is a result resource - you must have a string in there (that is a table name), show tables will return a list of all the tables so you have to pick which one you want and set $qruery1 to that value.

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.