Jump to content

budder

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

budder's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So it should look like this? $query = "UPDATE ticket_user SET order_nr = " . $_POST['order_nr'] . ", navn = " . $_POST['navn'] . ", billet_type = " . $_POST['billet_type'] . ", antal = " . $_POST['antal'] . ", afsendt = " . $_POST['afsendt'] . ", billet_nr = " . $_POST['billet_nr'] . ", WHERE order_id = " . $_POST['order_id']; Then I get this error again? :s You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Tomat, billet_type = Sommer Rock, antal = 7, afsendt = 20-10-2010, ' at line 3
  2. Always a good thing to remember. Thanks.
  3. Ups, totally forgot the $query. Hmm, I have tried to make space between the = an 17. But still get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE order_id = '17'' at line 8 Hust don't get it.. $query = "UPDATE ticket_user SET order_nr = '" . $_POST['order_nr'] . "', navn = '" . $_POST['navn'] . "', billet_type = '" . $_POST['billet_type'] . "', antal = '" . $_POST['antal'] . "', afsendt = '" . $_POST['afsendt'] . "', billet_nr = '" . $_POST['billet_nr'] . "', WHERE order_id = " . $_POST['order_id'];
  4. Hm, stil getting an error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE order_id =17' at line 8 First I did the following: query = 'UPDATE ticket_user SET order_nr ="' . $_POST['order_nr'] . '", navn ="' . $_POST['navn'] . '", billet_type ="' . $_POST['billet_type'] . '", antal ="' . $_POST['antal'] . '", afsendt ="' . $_POST['afsendt'] . '", billet_nr ="' . $_POST['billet_nr'] . '", WHERE order_id ="' . $_POST['order_id'] . '"'; But thsi gives me an error: Parse error: parse error in C:\wamp\www\billet\commit.php on line 89 and line 89 is: query = 'UPDATE ticket_user SET The line before and after 89: if(empty($error)) { //line88 order_nr ="' . $_POST['order_nr'] . '", // line 90
  5. I got this query that giving me error: $query = 'UPDATE ticket_user SET order_nr ="' . $_POST['order_nr'] . '", navn =' . $_POST['navn'] . ', billet_type = ' . $_POST['billet_type'] . ', antal = ' . $_POST['antal'] . ', afsendt =' . $_POST['afsendt'] . ', billet_nr =' . $_POST['billet_nr'] . ', WHERE order_id =' . $_POST['order_id']; I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Herhold, billet_type = Sommer Rock, antal = 4, afsendt =22-10-2010, ' at line 3
  6. In my billet.php I got this: (look at my first post codes in there) <form action="commit.php?action=<?php echo $_GET['action']; ?>&type=billet" methode="post"> It all starts at admin. Here there links that send information by the url like <a href="billet.php?action=add">ADD</a> In the billet.php you can add or edit the information. If you wanna add information the url is billet.php?action=add if it's editing then its billet.php?action=edit&id=#id In the commit.php it should see if you have chosen to edit og add (mysql:INSERT or UPDATE) It determents what to do buy the url. If action = add then INSERT if action = edit then UPDATE. I have posted the billet.php and commit.php at the top and the admin.php some posts up.
  7. Array ( [order_nr] => 54321 [navn] => Mag [billet_type] => Wulff [antal] => 5 [afsendt] => 2010-04-22 [order_id] => 1 [submit] => ) Array ( [order_nr] => 54321 [navn] => Magnus Herhold [billet_type] => Mikael Wulff [antal] => 5 [afsendt] => 2010-04-22 [order_id] => 1 [submit] => ) As you can see submit do not return anything. Hmm. Why can't i get my information any further? edit: The information isn't getting registered in billet.php even tough the link is sending the information billet.php?action=add or edit&id= on the admin page: <?php $db = mysql_connect('localhost', 'root') or die('unable to connect..'); mysql_select_db('my_db', $db) or die(mysql_error($db)); ?> <html> <head> <title>Billet Database</title> <style type="text/css"> th { background-color: #999; } .odd_row { background-color: #EEE; } .even_row { background-color: "FFF; } </style> </head> <body> <table style="width:100%;"> <tr> <th colspan="5">Billetter <a href="billet.php?action=add">[TILFØJ]</a></th> //add </tr> <?php $query = "SELECT * FROM ticket_user"; $result = mysql_query($query, $db) or die(mysql_error($db)); $odd = true; while ($row = mysql_fetch_assoc($result)) { if ($odd == true) { echo "<tr class='odd_row'>"; } else { echo "<tr class='even_row'>"; } $odd = !$odd; echo "<td style='width:10%;'>"; echo $row['order_nr']; echo "</td>"; echo "<td style='width:75%;'>"; echo $row['navn']; echo "</td><td>"; echo " <a href='billet.php?action=edit&id=" . $row['order_id'] . "'> [REDIGER]</a>"; //edit echo " <a href='delete.php?type=billet&id=" . $row['order_id'] . "'> [sLET]</a>"; //delete echo '</td></tr>'; } ?> </table>
  8. Im using the newest version of php. My url is: billet.php?action=edit&id= billet.php?action=add commit.php?action=<?php echo $_GET['action']; ?>&type=billet ---------------------------------^add/edit^--------------------------- commit should find out if the link is coming from the link billet.php?action=edit&id= or billet.php?action=add But i doesn't look like it taking anything from the url. Because my submit button doesn't have any name: <input type="submit" name="submit" value="<?php ucfirst($_GET['action']); ?>" />
  9. In this script I want to take som values out of the url. I want the script to discover what the action= and the type= is. But i seems to be an error: Notice: Undefined index: action in C:\wamp\www\billet\commit.php on line 12 It is not taking the value edit/add out of the url part:action=edit/add Some clues? commit.php <?php $db = mysql_connect('localhost', 'root') or die('unable to connect..'); mysql_select_db('my_db', $db) or die(mysql_error($db)); ?> <html> <head> <title>Commit</title> </head> <body> <?php switch ($_GET["action"]) { case "add": switch ($_GET["type"]) { case "billet": $query = "INSERT INTO ticket_user (order_nr,navn,billet_type,antal,afsendt) VALUES ('" . $_POST['order_nr'] . "', '" . $_POST['navn'] . "', '" . $_POST['billet_type'] . "', '" . $_POST['antal'] . "', '" . $_POST['afsendt'] . "')"; break; } break; case "edit": switch($_GET['type']) { case "billet": $query = "UPDATE movie SET order_nr ='" . $_POST['order_nr'] . "', navn ='" . $_POST['navn'] . "', billet_type = '" . $_POST['billet_type'] . "', antal = '" . $_POST['antal'] . "', afsendt ='" . $_POST['afsendt'] . "' WHERE order_id ='" . $_POST['id'] . "'"; break; } break; } if (isset($query)) { $result = mysql_query($query) or die(mysql_error($db)); echo "<p>Færdig!</p>"; } ?> </body> </html> the billet.php if needed: <?php $db = mysql_connect('localhost', 'root') or die('unable to connect..'); mysql_select_db('my_db', $db) or die(mysql_error($db)); if($_GET['action'] == 'edit') { $query = "SELECT order_nr, navn, billet_type, antal, afsendt FROM ticket_user WHERE order_id = " . $_GET['id']; $result = mysql_query($query, $db) or die(mysql_error()); extract(mysql_fetch_assoc($result)); } else { $order_nr = 0; $navn = ""; $billet_type = ""; $antal = 0; $afsendt = ""; } ?> <html> <head> <title><?php ucfirst($_GET['action']); ?> Movie</title> </head> <body> <form action="commit.php?action=<?php echo $_GET['action']; ?>&type=billet" methode="post"> <table> <tr> <td width="97">Order Nummer</td> <td width="149"><input type="text" name="order_nr" value="<?php echo $order_nr; ?>" /></td> </tr><tr> <td>Navn</td> <td><input name="navn" type="text" value="<?php echo $navn; ?>" /></td> </tr><tr> <td>Billet Type</td> <td><input name="billet_type" type="text" value="<?php echo $billet_type; ?>" /></td> </tr><tr> <td>antal</td> <td><input name="antal" type="text" value="<?php echo $antal; ?>" /></td> </tr><tr> <td>Afsendt</td> <td><input name="afsendt" type="text" value="<?php echo $afsendt; ?>" /></td> </tr> <td colspan=”2” style="text-align: center;"> <?php if ($_GET['action'] == "edit") { echo "<input type='hidden' value='" . $_GET['id'] . "' name='order_id' />"; } ?> <label> <input type="submit" name="submit" value="<?php ucfirst($_GET['action']); ?>" /> </label></td></table></form> </body></html>
  10. Hey sorry for putting the same code in that is a mistake. I have edited the error that was present in the script. There are no errors in my script (there is but they are not showed when running the script) but it is not working as I have in mind. As I said in the start it would not login but the $error do not activate as it should if the pass or user is wrong. It's only showing blank page with this in the url: login.php?username=mahe04&redirect=&submit=login Here is the code: <?php session_start(); $dbHost = "sql01.dk"; $dbUser = "elmerdahldk"; $dbPass = "rNnj5Tc2"; $dbDatabase = "elmerdahldk"; $db = mysql_connect($dbHost,$dbUser,$dbPass) or die("Unable to connect."); mysql_select_db($dbDatabase, $db) or die(mysql_error($db)); if (isset($_POST['username'])) { $username = trim($_POST['username']); } else { $username = ""; } if (isset($_POST['password'])) { $password = $_POST['password']; } else { $password = ""; } if (isset($_REQUEST['redirect'])) { $redirect = $_REQUEST['redirect']; } else { $redirect = "main.php"; } if (isset($_POST['submit'])) { $query = "SELECT username FROM site_user WHERE username='" . mysql_real_escape_string($username) . "' AND password = password('" . mysql_real_escape_string($password) . "')"; $result = mysql_query($query, $db); if (mysql_num_rows($result) > 0) { $_SESSION["username"] = $username; $_SESSION['logged'] = 1; header("Refresh: 5; URL=" . $redirect); echo "<p>Du vil blive sendt videre om 5 sekunder.</p>"; echo "<p>Hvis du ikke bliver sendt videre så klik <a href='" . $redirect . "'>her</a></p>"; die(); } else { $error = "<p>Du har angivet et forkert brugernavn eller kodeord. Prøv igen.</p>"; } } ?> <html> <head> <title>Login</title> </head> <body> <?php if (isset($error)) { echo $error; } ?> <form action="login.php" method"post"> <table> <tr> <td>Username:</td> <td><input type="text" name="username" maxlength="20" size="20" value="<?php echo $username; ?>" /> </td> </tr><tr> <td>Password:</td> <td><input type="password" maxlength="20" size="20" value="<?php $password; ?>" /></td> </tr><tr> <td> </td> <td> <input type="hidden" name="redirect" value="<?php echo $redirect ?>" /> <input type="submit" name="submit" value="login" /> </tr> </table> </form> </body> </html> Yes it look like the same code, the difference is that there is no error even when there should be. If the username and password is invaild it should show the $error message.
  11. Hey phpfreaks. I wonder if this script would log any of you in, because I'm not getting anywhere when trying. The only thing that happens when i run the script and typing the login information in, is that it refreshes. There is no error in $error and that I don't understand because it should login or display the error message. But maybe it's just me (: <?php session_start(); $dbHost = "s"; $dbUser = "u"; $dbPass = "u"; $dbDatabase = "t"; $db = mysql_connect($dbHost,$dbUser,$dbPass) or die("Unable to connect."); mysql_select_db($dbDatabase, $db) or die(mysql_error($db)); if (isset($_POST['username'])) { $username = trim($_POST['username']); } else { $username = ""; } if (isset($_POST['password'])) { $password = $_POST['password']; } else { $password = ""; } if (isset($_REQUEST['redirect'])) { $redirect = $_REQUEST['redirect']; } else { $redirect = "main.php"; } if (isset($_POST['submit'])) { $query = "SELECT USERNAME FROM site_user WHERE username='" . mysql_real_escape_string($username, $db) . "' AND password = password('" . mysql_real_escape_string($password, $db) . "') $result = mysql_query($query, $db) if (mysql_num_rows($result) > 0) { $_SESSION['username'] = $username; //Line 33 that makes the error. $_SESSION['logged'] = 1; header("Refresh: 5; URL=" . $redirect); echo "<p>Du vil blive sendt videre om 5 sekunder.</p>"; echo "<p>Hvis du ikke bliver sendt videre så klik <a href='" . $redirect . "'>her</a></p>"; die(); } else { $error = "<p>Du har angivet et forkert brugernavn eller kodeord. Prøv igen.</p>"; } } ?> <html> <head> <title>Login</title> </head> <body> <?php if (isset($error)) { echo $error; } ?> <form action="login.php" method"post"> <table> <tr> <td>Username:</td> <td><input type="text" name="username" maxlength="20" size="20" value="<?php echo $username; ?>" /> </td> </tr><tr> <td>Password:</td> <td><input type="password" maxlength="20" size="20" value="<?php $password; ?>" /></td> </tr><tr> <td> </td> <td> <input type="hidden" name="redirect" value="<?php echo $redirect ?>" /> <input type="submit" name="submit" value="login" /> </tr> </table> </form> </body> </html>
  12. Excellent no problems now. The mysql_real_escape_string($username, $db) works with and without $db (:
  13. Now the error have moved to the line above with the error: Parse error: syntax error, unexpected T_IF in login.php on line 32
  14. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /login.php on line 33 Is it the variable $username that making the error? If so what to do? <?php session_start(); $dbHost = "s"; $dbUser = "u"; $dbPass = "u"; $dbDatabase = "t"; $db = mysql_connect($dbHost,$dbUser,$dbPass) or die("Unable to connect."); mysql_select_db($dbDatabase, $db) or die(mysql_error($db)); if (isset($_POST['username'])) { $username = trim($_POST['username']); } else { $username = ""; } if (isset($_POST['password'])) { $password = $_POST['password']; } else { $password = ""; } if (isset($_REQUEST['redirect'])) { $redirect = $_REQUEST['redirect']; } else { $redirect = "main.php"; } if (isset($_POST['submit'])) { $query = "SELECT USERNAME FROM site_user WHERE username='" . mysql_real_escape_string($username, $db) . "' AND password = password('" . mysql_real_escape_string($password, $db) . "') $result = mysql_query($query, $db) if (mysql_num_rows($result) > 0) { $_SESSION['username'] = $username; //Line 33 that makes the error. $_SESSION['logged'] = 1; header("Refresh: 5; URL=" . $redirect); echo "<p>Du vil blive sendt videre om 5 sekunder.</p>"; echo "<p>Hvis du ikke bliver sendt videre så klik <a href='" . $redirect . "'>her</a></p>"; die(); } else { $error = "<p>Du har angivet et forkert brugernavn eller kodeord. Prøv igen.</p>"; } } ?> <html> <head> <title>Login</title> </head> <body> <?php if (isset($error)) { echo $error; } ?> <form action="login.php" method"post"> <table> <tr> <td>Username:</td> <td><input type="text" name="username" maxlength="20" size="20" value="<?php echo $username; ?>" /> </td> </tr><tr> <td>Password:</td> <td><input type="password" maxlength="20" size="20" value="<?php $password; ?>" /></td> </tr><tr> <td> </td> <td> <input type="hidden" name="redirect" value="<?php echo $redirect ?>" /> <input type="submit" name="submit" value="login" /> </tr> </table> </form> </body> </html>
×
×
  • 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.