RaRa3 1 Posted April 13, 2015 Report Share Posted April 13, 2015 (edited) hello so i am making a registration page using html and php, i need to make the information send to mysql that i made with table but i never made select statements..i am not sure on how to make it i need help i am new to this so please bare with me. So I this code to connect to mysql none I am not sure how to fix it i know there must be a problem with the code for the submit line and with the isset. I got them from another user but made minor changes to fit my database. My database has 2 tables one named UserAccount with the information listed in the registration page and then another table named Cart for purchases to be made. Please if you can help me with my code or if you see other errors i think i might have an error with my php where i put firstName, and etc. and if you know any other material or links that would help me for making product information and a cart send to a database if you can share it, im trying but having many issues Edited April 14, 2015 by RaRa3 Quote Link to post Share on other sites
Ingolme 1,033 Posted April 13, 2015 Report Share Posted April 13, 2015 It looks like you have an invalid character as your string delimiter, you can see it clearly when the code is highlighted. This is the problem: include('connect.php’); There are other problems, such as the variables names used here: $conn = mysqli_connect($Shop, $root, $password); Quote Link to post Share on other sites
RaRa3 1 Posted April 13, 2015 Author Report Share Posted April 13, 2015 oh thanks i missed that i dont know why anytime i edit a word in quotations it automatically changes the delimiter, but also i have a question for that line $conn = mysqli_connect($Shop, $root, $password); my database name is called shop, and the username is root and the password is a actual password but i put password so i dont reveal it, now do i actually change them to fit the description of the database or put $hostname, $username, $ password ? does the "$" also need to be included? Quote Link to post Share on other sites
Ingolme 1,033 Posted April 13, 2015 Report Share Posted April 13, 2015 The $ indicates a variable, which is explained in the W3Schools PHP tutorial. If you don't want a variable, then you can use a string: $conn = mysqli_connect('shop', 'root', 'password'); What program are you using to edit your code? If it's converting your single-quotes to fancy quotes, then it's clearly not a coding environment you're working in. Quote Link to post Share on other sites
RaRa3 1 Posted April 13, 2015 Author Report Share Posted April 13, 2015 (edited) ohhh okay well im using textedit i have a mac, i know i should use netbeans or something but idk i feel comfortable with textedit, now also im getting an error for the connect php file Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Applications/XAMPP/xamppfiles/htdocs/connect.php on line 7Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Applications/XAMPP/xamppfiles/htdocs/connect.php on line 7Connection failed: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known Edited April 13, 2015 by RaRa3 Quote Link to post Share on other sites
RaRa3 1 Posted April 13, 2015 Author Report Share Posted April 13, 2015 i updated my codes Quote Link to post Share on other sites
Ingolme 1,033 Posted April 13, 2015 Report Share Posted April 13, 2015 Actually, the first parameter of the mysqli_connect() function is the name of the database server. It's often "localhost", but might be something else, for example "sql.webhost.com" I suggest you read the whole PHP tutorial so you can understand the concepts more clearly. Quote Link to post Share on other sites
RaRa3 1 Posted April 13, 2015 Author Report Share Posted April 13, 2015 should the line look like this? $conn = localhost(‘Shop','root','password'); thanks im going to read about it now does it mention about how sql works with php? Quote Link to post Share on other sites
Ingolme 1,033 Posted April 13, 2015 Report Share Posted April 13, 2015 The tutorial does have a MySQL section, but you really need to learn the basics, because your current mistakes are with the core syntax of PHP. localhost is not a function, it's a server name, so you would put it as the first parameter of the mysqli_connect function. Once you learn PHP you should know what "parameter" means and what a function is. 1 Quote Link to post Share on other sites
RaRa3 1 Posted April 13, 2015 Author Report Share Posted April 13, 2015 okay ill check it out, thank you! Quote Link to post Share on other sites
RaRa3 1 Posted April 13, 2015 Author Report Share Posted April 13, 2015 Connected successfullyNotice: Undefined index: firstName in /Applications/XAMPP/xamppfiles/htdocs/register.php on line 7please fill the empty field. i fixed it and got connected successfully but i still dont see an error in that line..idk Quote Link to post Share on other sites
justsomeguy 1,135 Posted April 13, 2015 Report Share Posted April 13, 2015 An undefined index error means that you're trying to access an array element that doesn't exist. You can use isset to check if it exists before trying to access it.http://php.net/manual/en/function.isset.php 1 Quote Link to post Share on other sites
Ingolme 1,033 Posted April 13, 2015 Report Share Posted April 13, 2015 I would suggest learning about SQL injection. Otherwise, your site is very open to hacking. Quote Link to post Share on other sites
RaRa3 1 Posted April 14, 2015 Author Report Share Posted April 14, 2015 thanks so much! i got it to work! now im working on a login, thank you! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.