|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have been very successful with EasyPHP and Win.2000 but I'm still having problems. The first problem I corrected by switching text editors. I started with Notepad but it kept sticking a .txt extension on the end and that drove me crazy for a few days. Once I switched and started writing real .php docs I was in-like-Flin. Thanks for everyones help.
Now I am having trouble connecting to mySQLdatabase, although I have no trouble using PHPmyadmin to create tables, databases, etc. I get a parse error with the following code: first what I'm using... apache 1.3.24.+ , PHP 4.2.0 and mysql (latest)... Here is the code: <? PHP $db = @mysql_connect("localhost", "root", ""); mysql_select_db("myfirstdb",$db); if ($submit) { // here if no ID then adding else we're editing if ($id) { $sql = "UPDATE booksbd SET booktitle ='$booktitle',author='$author',publisher='$publish er',summery ='$summery',inputby ='$inputby', WHERE id=$id"; } else { $sql = "INSERT INTO booksbd (booktitle,author,publisher,summery,inputby) VALUES ('$booktitle','$author','$publisher','$summery', '$inputby')"; } * I wanted to enclose the above code in red, php code, but I don't know how... ![]() I'm so close, can anyone help? Thanks.
__________________
bow wow! |
|
#2
|
|||
|
|||
|
whoa! a few big problems, here.
Firstly im guessing that you used to use 4.0 and have only made the switch reciently to 4.2. Ok firstly, if your connecting to your database server via phpmyadmin without any hassels, then everything is set up correctly. Im asuming that you have the right connection details, so lets move on if ($submit) { // here if no ID then adding else we're editing if ($id) { $sql = "UPDATE booksbd SET booktitle ='$booktitle',author='$author',publisher='$publish er',summery ='$summery',inputby ='$inputby', WHERE id=$id"; } else { $sql = "INSERT INTO booksbd (booktitle,author,publisher,summery,inputby) VALUES ('$booktitle','$author','$publisher','$summery', '$inputby')"; } here lies your problem, firstly you want to insert or update data into the database, currently all your doing is setting a value of a $VARIABLE. you actually need to query the database like this PHP Code:
next im asuming that this page is loaded after you hit the submit button, in which case, it wont get past the if ($submit) { line. 4.2.x uses superarray globals, so basically this means, that you cant call a post $variable as $submit. you will need to do it like this PHP Code:
next problem your queries are calling $var, from POST variables you will also need to use $_POST but you will need to place them in curly brackets {} since your setting them in a variable an example $sql = "SELECT * FROM books WHERE field = {$_POST['id']}"; something like that PHP Code:
|
|
#3
|
|||
|
|||
|
Wow, I've much to learn!
Thanks, I'll get to the changes. I'll post another reply once these are in place and I test it again! Thanks again.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > Success with EasyPHP! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|