Error in SQL Syntax HELP!!!
Posted on
16th Feb 2014 07:03 pm by
admin
I have this page:
Code: <?php
session_start();
//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());
//show scouts characters
$get_scouts = "select * from scouts where username = '".$_SESSION['userName']."'";
$get_scouts_res = mysql_query($get_scouts, $conn) or die(mysql_error());
while ($list_scouts = mysql_fetch_array($get_scouts_res)) {
$identity = ucwords($list_scouts['identity']);
$topic_id = $list_scouts['id'];
echo "<ul class="character_list"><li><a href="fight.php?identity=$identity">$identity</li></ul> ";
}
?>
And it goes to this page:
Code: <?php
session_start();
//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());
//check for required info from the query string
if (!$_GET['identity']) {
header("Location: train_fight.php");
exit;
}
//get derived values
$derived = "select * from derived_values where identity = $_GET[identity]";
$derived_res = mysql_query($derived, $conn) or die(mysql_error());
$display_block = "<ul>";
while ($derived_info = mysql_fetch_array($derived_res)) {
$derived_id = $derived_info['id'];
$derived_identity = $derived_info['identity'];
$derived_health = $derived_info['health'];
$derived_energy = $derived_info['energy'];
$derived_acv1 = $derived_info['acv1'];
$derived_acv2 = $derived_info['acv2'];
$derived_dcv1 = $derived_info['dcv1'];
$derived_dcv2 = $derived_info['dcv2'];
$derived_total_cp = $derived_info['total_cp'];
$display_block .= "<li>$derived_identity</li>";
}
$display_block .= "</ul>";
?>
But I am getting this error:
You have an error in your SQL syntax; check the manual that correspondsto your MySQL server version for the right syntax to use atline 1
What am I doing wrong here? If I change my where statement or take it out, it is displaying the information, but I can't figure out what's wrong with my where statement or where I'm getting my "identity" from. Something's wrong but I can't find it. Can anyone help?
No comments posted yet
Your Answer:
Login to answer
136 33
Other forums
Fatal error: Call to a member function fetchrow() on a non-object in C:xamppht
okay i have this query and everytime i add `item_id`=? to it... it gives me the error in the title..
Output Buffering question
Hi all,
I've been trying to wrap my head around output buffering. So far I've found tons of
PHP IMAGE UPLOAD SCRIPT
Hi for the last week i have been looking for scripts that will upload a photo to a certain folder wh
parse error
Parse error: syntax error, unexpected '[', expecting ')' in /Users/admin/Sites/phptest/array.php on
How to Detect it is public_html or httpdocs?
How to check whether it is cPanel or Plesk?
If it found public_html perform <?php incl
Validating time
Hi Guys
what do you think of the following approach to validate a 24hour time:
http://
Number Format
Hi All,
I have number '000000000050085' I want to format it to 500.85 Can any one give me
How to generate a text file using php...?
Hi,
Can anyone give me code to generate a text file using php
Thanks in advance
Need help with unexpected T-STRING error
I'm a newbie and I'm still learning PHP. However this error has me stumped. I've googled, searched t
form variables from database help.
Hi all,
I would like to have a form that gives you options based on the results of an mysql q