Jump to content

SteelyDan

New Members
  • Posts

    8
  • Joined

  • Last visited

SteelyDan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok so I got the page to appear (figured out the parse error above). I can click submit, and it echos a little table in my document, but the table has no results in it. It only has the headers. Even when I modify the string to SELECT * FROM weapons; I get no results (and yes, the database has entries in it). (SORRY JAZZMASTER, YOU POSTED LITERALLY 5 SECONDS BEFORE I DID, haha) Here was the fix for the code above (or so I think. Maybe it is still the problem); $searchstring = "SELECT buildname,weapon,category,id,author FROM weapons " . "WHERE buildname='$buildname' AND weapon='$weapon' AND category='$category' AND id='$id'"; Alterations include; using AND instead of commas, and using single quotations around the variables. Any help on getting my results to show? Thanks, Nick I should also mention I realized I forgot to assign my variables from the $_POST array, so this was the code I added in. $buildname = sanitizeString($_POST['buildname']); $weapon = ($_POST['weapon']); $category = ($_POST['category']); $id = ($_POST['id']);
  2. Hey Jazzman1, I just saw SteelyDan last Sunday @ the Molson Amphitheatre in Toronto, haha. But yeah, I guess what I'm asking is a) Can I use the WHERE clause to include more than one value? and if not... b) How do I perform this function? and c) Would you mind pointing out my error? Lol I have already looked at the WHERE clause in mySQL documentation, and it doesn't talk about using more than one variable. Nick
  3. Hey -- I'm making a search engine for users to search my site, and I want them to only have to enter at least one of the four fields I have set out for them, in order to make a search. I think I have the code right to do that. However, since it is AT LEAST 1 field, the other fields are set to wildcards. I want my script to SELECT (5 different columns) FROM (a table called weapons) WHERE (their input = the values of the fields in each of the 5 columns). Does that make sense? Here is my code (A few lines down). I get an error saying: Parse error: syntax error, unexpected '$buildname' (T_VARIABLE) in C:\web\search_query.php on line 39 Leading me to believe I have written my query wrong. Apart from that, I want to generate a table when this search is conducted. Will my method work? I basically echo the table start tag with headers, Perform a loop which has the results in each new row, Close the table header tag. This seemed like the most logical way for me to do it. Let me know if this is wrong or there is a better way to do it. But most importantly, I'd like help fixing this error and getting the proper MySQL SELECT>>>FROM>>>WHERE>>>a=$"var1", b=$"var2", c="var3"; <?php //submit_build.php include_once 'header.php'; require_once 'login_builds.php'; include_once 'functions.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); if (isset($_POST['buildname']) || isset($_POST['weapon']) || isset($_POST['category']) || isset($_POST['id'])) { if ($_POST['buildname'] == "") { $buildname = "*"; } if ($_POST['weapon'] == "") { $weapon = "*"; } if ($_POST['category'] == "") { $category = "*"; } if ($_POST['id'] == "") { $id = "*"; } $buildname = sanitizeString($_POST['buildname']); $searchstring = "SELECT buildname,weapon,category,id,author FROM weapons " . "WHERE buildname="$buildname", weapon="$weapon", category="$category", id="$id""; $result = mysql_query($searchstring); if (!$result) die ("Database access failed: " . mysql_error()); $rows = mysql_num_rows($result); echo<<<_END <table class="fixed"> <tr> <td class="newsbody">ID</td> <td class="newsbody">Build Name</td> <td class="newsbody">Weapon</td> <td class="newsbody">Category</td> <td class="newsbody">Author</td> </tr> _END; for ($j = 0; $j < $rows; ++$j) { echo<<<_END <tr> <td class="newsbody">$row[3]</td> <td class="newsbody"><a href="builds/$row[0].php">$row[0]</a></td> <td class="newsbody">$row[1]</td> <td class="newsbody">$row[2]</td> <td class="newsbody">$row[4]</td> </tr> _END; } echo<<<_END </table> _END; } echo<<<_END <html xmlns="http://www.w3.org/1999/xhtml"> <head> // FORM STARTS HERE, I JUST CHOSE TO HIDE IT BECAUSE IT IS LIKE 3000 LINES LONG Hopefully I made myself clear. Cheers! Nick
  4. Genius, that did it! Gotta plow through a few more errors now, but that was one I never would have figured out. Thank you so much! Nick
  5. Hey again, wondering if I can get some help with finding the error in my code here. I'm creating a string to query my MySQL database with, and keep getting the following error: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\web\submit_build.php on line 56 <?php //submit_build.php include_once 'header.php'; require_once 'login_builds.php'; include_once 'functions.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); if (isset($_POST['buildname']) && isset($_POST['weapon']) && isset($_POST['mod1']) && isset($_POST['mod2']) && isset($_POST['mod3']) && isset($_POST['mod4']) && isset($_POST['mod5']) && isset($_POST['mod6']) && isset($_POST['mod7']) && isset($_POST['mod8']) && isset($_POST['polarity1']) && isset($_POST['polarity2']) && isset($_POST['polarity3']) && isset($_POST['polarity4']) && isset($_POST['polarity5']) && isset($_POST['polarity6']) && isset($_POST['polarity7']) && isset($_POST['polarity8']) && isset($_POST['description']) && isset($_POST['password'])) { $buildname = sanitizeString($_POST['buildname']); $weapon = sanitizeString($_POST['weapon']); $mod1 = sanitizeString($_POST['mod1']); $mod2 = sanitizeString($_POST['mod2']); $mod3 = sanitizeString($_POST['mod3']); $mod4 = sanitizeString($_POST['mod4']); $mod5 = sanitizeString($_POST['mod5']); $mod6 = sanitizeString($_POST['mod6']); $mod7 = sanitizeString($_POST['mod7']); $mod8 = sanitizeString($_POST['mod8']); $polarity1 = sanitizeString($_POST['polarity1']); $polarity2 = sanitizeString($_POST['polarity2']); $polarity3 = sanitizeString($_POST['polarity3']); $polarity4 = sanitizeString($_POST['polarity4']); $polarity5 = sanitizeString($_POST['polarity5']); $polarity6 = sanitizeString($_POST['polarity6']); $polarity7 = sanitizeString($_POST['polarity7']); $polarity8 = sanitizeString($_POST['polarity8']); $description = sanitizeString($_POST['description']); $pw_check = md5($_POST['password']); if ($pw_check == $password) { $add_build = "INSERT INTO builds VALUES(NULL,'$username','$buildname','$weapon','mod1','mod2','mod3','mod4','mod5','mod6','mod7','mod8','polarity1','polarity2','polarity3','polarity4','polarity5','polarity6','polarity7','polarity8','$description',NULL,'$_SESSION['ipaddress']')"; mysql_query($add_build); header("Location: account.php"); } else{ die("Incorrect password."); } ?> Thanks a bunch! Nick
  6. Got it--- Haha sorry for the triple post. This is all I had to do: if ($loggedin == TRUE) { echo <<<_END <html xmlns="http://www.w3.org/1999/xhtml"> <head> Just had to add return whitespace at the end of it. Who knew. Thanks! (lol)
  7. Also, I googled it, and tried the solutions other people found (removing spaces before and after the _END as well as changing the name to not include and underscore at the beginning, nothing worked.
  8. Hey guys, probably a nub question, but here it goes: Why am I getting the following error with my following code? Everything seems in place to me, I've looked it over a thousand times: ERROR: Parse error: syntax error, unexpected '<<' (T_SL) in C:\web\header.php on line 15 CODE: <?php //header.php include_once 'login_users.php'; session_start(); if (isset($_SESSION['username'])) { $username = $_SESSION['username']; $loggedin = TRUE; } else $loggedin = FALSE; if ($loggedin == TRUE) { echo <<<_END <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="en-us" http-equiv="Content-Language" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <style> body { margin: 0px 0px 0px 0px; } #table_header { display: block; height: 30px; margin-left: 0px; background-image:url('images/stripe_bg.jpg'); position: static; } #header_div { display: block; height: 10px; margin-left: 0px; background-image:url('images/greystripe_bg.jpg'); } .headertext { text-align: right; font-family: Colaborate-Thin; color: white; font-size: large; text-align: right; } .textab { font-family: Colaborate-Thin; text-align: right; color: #FFFFFF; </style> <title>Untitled 1</title> </head> <body> <table id="table_header" style="width: 100%"> </table> <div id="header_div"> </div> </body> </html> _END; } else { echo <<<_END <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="en-us" http-equiv="Content-Language" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <style> body { margin: 0px 0px 0px 0px; } #table_header { display: block; height: 30px; margin-left: 0px; background-image:url('images/stripe_bg.jpg'); position: static; } #header_div { display: block; height: 10px; margin-left: 0px; background-image:url('images/greystripe_bg.jpg'); } .headertext { text-align: right; font-family: Colaborate-Thin; color: white; font-size: large; text-align: right; } .auto-style1 { font-family: Colaborate-Thin; text-align: right; color: #FFFFFF; } .auto-style2 { color: #FFFFFF; } </style> <title>Untitled 1</title> </head> <body> <table id="table_header" style="width: 100%"> </table> <div id="header_div"> </div> </body> </html> _END; } ?> Thanks for your help! I've never seen this one before and have no idea where to begin looking. (Line 15, duh, but I feel like the syntax error is occuring somewhere else, lol)
×
×
  • 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.