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
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);

Link to comment
Share on other sites

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();
	}
}
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.