Jump to content

Adam Brave

  • Posts

  • Joined

  • Last visited

Adam Brave's Achievements


Newbie (1/7)



  1. I have a form defined by the following code: <form name="input" action="insert.php" method="get"> <input type="text" name="meeting"><input type="Submit" value="Gravar"></form> And, in other file (insert.php), I want to insert in the database the information that the user introduced onto the form with the following code: <?php session_start(); ?><html><body><?php $link = mysqli_connect('localhost', 'root');if (!$link) { die('Nao foi possivel conectar: ' . mysqli_error()); }else{echo 'Conexao bem sucedida';echo "<br />";}mysqli_select_db("databasexpto", $link); $appoint = mysqli_query("INSERT INTO appointments (`what`, `owner`) VALUES('$_POST['meeting']','$_SESSION['userID']')"); if (!mysqli_query($link,$sql)) {die('Error: ' . mysqli_error());}else{ echo "1 record added";} mysqli_close($link);?></body></html> When I execute the code I receive 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:\Program Files\EasyPHP-12.1\www\files\insert.php on line 21 Can someone help me?
  2. That works in javascript but not in php. I want a instruction that works inside of the tags <?php ... ?>
  3. Solved $result = mysql_query(SELECT * FROM userdb WHERE mail LIKE '$maill' AND pass LIKE '$passwordd'); Btw, can someone tell me how do I load a html page with php code? In javascript I would use the instruction location.href but how do I load a page with php?
  4. Well I was in fact trying to use an access database LOL that may be the problem.I wil try to change to a sql database then
  5. I have changed the code to this: $maill = $_POST['fmail'];$passwordd = $_POST['fpass'];$mysqli = new mysqli("localhost",$maill,"");/* check connection */if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit();}$mysqli->select_db("database.accdb");$result = $mysqli->query("SELECT * FROM user WHERE mail=$maill AND password=$passwordd");$row = $result->fetch_row();printf("Default database is %s.\n", $row[0]); And my output is: "Fatal error: Call to a member function fetch_row() on a non-object in C:\Program Files\EasyPHP-12.1\www\welcome.php on line 27" Line 27 : $row = $result->fetch_row(); Now, I'm sure that I have a row in my database with the mail and password stored on the variables $maill and $password and, I'm also sure, that these variables have the corresponding information so why can't I validate that user?
  6. From what I see, the information submitted by the user (mail=asd@hotmail.com and password=asd) have something wrongon the password. For example I printed the two variables and get this: <form action="welcome.php" method="post">mail: <input type="text" name="fmail">password: <input type="text" name="fpass"><input type="submit"></form>...$maill = $_POST['fmail'];$passwordd = $_POST['fpass'];echo $maill;echo "<br>";echo $passwordd; Output:asd@hotmail.comasdbool(false) From where come the "bool(false)" ?
  7. Hi, I want to make a login and a validation in a database. In order to do it I use the following code where: user -> table with all the user information like birthday, mail, username, first name etcpassword -> column of the table "user" that contains all the passwordsmail -> column of the table "user" that contains all the mails. The two variables, $maill and $passwordd, are use to store the information required at the login moment to the user. $result = mysql_query("SELECT password FROM user WHERE mail=$maill");$row = mysql_fetch_array($result); if ( $row['mail'] == $maill && $row['password'] == $passwordd ){ echo $row['name'] . " " . $row['ultimonome']; } else { echo "login not correct"; } Output: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files\EasyPHP-12.1\www\welcome.php on line 29login not correct Can someone help me?
  8. Just one last question a little bit offtopic. I have this two lines of code: month = document.calForm.selMonth.options[document.calForm.selMonth.selectedIndex].value;month += 1; What I expected that should happen was the variable "month" to be incremented, but what really happen is that if "month" is equal 5 on the end of the first line then in the second line it will result "51" . The instruction "month += 1" does not do a numerical calculation, instead, it joins "1" to the previous value of the variable. How can I change this?
  9. Solved: myJSON = '{ "jday" : "' + day + '", "jmonth" : "' + month + '", "jyear" : "' + year + '" }'; Tkz for the help
  10. Well it works with just the jday but when I do this on the first file: myJSON = { "jday" : "' + day + '", "jmonth" : "' + month + '", "jyear" : "' + year + '"}; I can't see none of the three elements
  11. But with the true parameter what I get is: " array(1) { ["jday"]=> string(2) "24" } "
  12. With the decode: <?php$dayphp = $_GET['xpto'];$obj = json_decode($dayphp);echo $dayphp;?> My output is: "object(stdClass)#1 (1) { ["jday"]=> string(2) "24" } " =\
  • Create New...