|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Install script freakout
Hey! I'm trying to create a script which will "install" a website on a server by creating all the tables and the database for it to work. So that there is no manual setup needed except putting the folder on the server and then filling in the neccessary server information in the beginning of the script.
Buuuut, I get a php syntax error. It says unexpected '=' on line 30 ($httpdir-uploaded_files). And if I comment that bit of code so the script ignores it then it just goes to the next "=" and says there is an error there too! I can't find any syntax error in my code, though am I fairly new to php and SQL, this is my first website I've created with it. Here below is the code. Please post any ideas you might have! ![]() PHP Code:
|
|
#2
|
|||
|
|||
|
hyphens are not allowed in variable names. Switch it to an underscore.
PHP.net:Variables Quote:
Code:
$httpdir_uploaded_files = $httproot.'/admin/edit/uploaded_files/'; |
|
#3
|
|||
|
|||
|
Thanks! that worked great! Now I have another problem though. There is something wrong with my code again. This is the error message i 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 '�ngens Redovisningsservice and 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 'default) VALUE ( 'Contact', 'KRS - Kungsängens Redovisningsservic' What could be the problem? Last edited by gunnarflax; 11-03-2009 at 11:27 AM. |
|
#4
|
|||
|
|||
|
again, I'm seeing some hyphenated variable further down the page.
Code:
$content-home $content-contact PHP Code:
If you copy/paste the 'KRS - Kungsanges...' you also might have grabbed an unencoded n-dash, which might be throwing another wrench. Try replacing that with a manual soft-hyphen (the minus "-" key) and see if that clear it up. Last edited by OctoberWind; 11-03-2009 at 03:19 PM. |
|
#5
|
|||
|
|||
|
I've actually changed all the variables and a couple of other errors I received. I just haven't uploaded the new code. I will try what you suggested and then edit and upload the new code. Thanks!
|
|
#6
|
|||
|
|||
|
Okay, here I got my current code:
PHP Code:
|
|
#7
|
|||
|
|||
|
Is "default" a reserved word in mySQL? Try using `default` (notice they are backticks and not single quotes) and see if that works.
|
|
#8
|
|||
|
|||
|
still doesn't work, this is exactly the error I receive now:
Error när Hem-sidan skulle registreras: 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 '�ngens Redovisningsservice Välkommen till oss! Vi är den lilla ' at line 5Error när Kontakt-sidan skulle registreras: 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 '/h1> * Ringv. 14, Box 2031 * 196 02 KUNGSÄNGE' at line 5Error när sidfoten skulle registreras: Table 'test.footer' doesn't exist |
|
#9
|
|||
|
|||
|
I've switched the word "default" for "base" now and I had both " and ' in the beginning of the $content_home and contact variable which I've now fixed for just the ".
Now I get this error message: Error när Hem-sidan skulle registreras: Table 'test.pages' doesn't existError när Kontakt-sidan skulle registreras: Table 'test.pages' doesn't existError när sidfoten skulle registreras: Table 'test.footer' doesn't exist And I don't understand why it won't work! |
|
#10
|
|||
|
|||
|
A good rule of thumb when working with databases is to use mysql_real_escape_string for all string input. This will help with SQL injection in scripts that handle user input and also help to prevent SQL errors due to unrecognized characters being submitted to the database. I don't speak the language that those errors are written in, could you translate to English and perhaps I can help?
|
|
#11
|
|||
|
|||
|
why are you double-quoting this string:
PHP Code:
Also, it's only asking for more problems to be concatenating that string line by line. You mess up on one " . " and you're whole sting is fubar'd. All that's doing for you is writing the HTML out into one enormously long line which is probably the opposite of what you're trying to do (to make a more human-readable source code?). You can hard-return inside of the double-quote string, and it'll still work fine. PHP Code:
|
|
#12
|
|||
|
|||
|
I noticed the double quotation too and removed it. I change the content of the variables too so that it makes better source code, I though that was what I was doing
Still have a lot to learn thoughCriterion I haven't learned about mysql_real_escape_string yet, I will have to read about it on w3schools tomorrow. The errors I receive is in english already except what I myself echo when the error occurs, which just says that an error occurred. But it also prints the mysql error. You can compare the lines which get echoed with the error reports I have in the script and you will se where the error is. I hope it is as easy to understand as I want to beleive it is ^^ Last edited by gunnarflax; 11-05-2009 at 04:38 PM. Reason: response to another reply |
|
#13
|
|||
|
|||
|
Thank you all for your help! I've now gotten it to work! the last problem I had was because I didn't run the query with $sql when I wanted to create the pages table, only when I wanted to insert the content. Therefore I had no table to insert the information into.
Is it really necessary to use mysql_real_escape_string() when don't have a user input that has any effect with that variable? like I do with $content_home. When I tried using it it wrote \r\n into the database instead of actually break a line. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|