Jump to content

Table?


Recommended Posts

The error is here:

if(mysql_query($sql,$con));{echo 'Table created';};else{die('Could not create table: ' . mysql_error());}

There are 2 semicolons that shouldn't be there. One is on the first line, and one is before the else. Neither of them belong there. The first one tells PHP that the if statement is this:if(mysql_query($sql,$con));Just that. That says that if mysql_query was true.. do nothing. The semicolon stops it from doing anything else, so PHP considers it an error when it gets to the else and sees that it's not attached to any if. That code is the same as this:

if(mysql_query($sql,$con)){  // do nothing}{// this will always run, it is not part of the ifecho 'Table created';};else // error, because the else is not attached to an if{die('Could not create table: ' . mysql_error());}

Link to post
Share on other sites
  • Replies 165
  • Created
  • Last Reply

Top Posters In This Topic

I finally managed, but I don´t like it! I copied and paste the tutorial. Now I am going to compare these 2.

Link to post
Share on other sites

What do you mean you don't like it! Hello we are not shopping for shoes here! Remember your are learning through trial an error, at this point a run without error messages should put a big smile on your face.

Link to post
Share on other sites
What do you mean you don't like it! Hello we are not shopping for shoes here! Remember your are learning through trial an error, at this point a run without error messages should put a big smile on your face.
I know! But trial an error 4 days? At this moment I am fed up of semi coloms! Edited by eduardchile
Link to post
Share on other sites

You also use exclamation points a lot, it always looks like you're yelling at us. Get used to semicolons, you'll see them a lot in code. If you were actually selling your services doing this stuff, you would need to be able to find and fix basic errors like that. It's also time to get friendly with quotes, parentheses, square brackets, and curly brackets.

Link to post
Share on other sites
I know! But trial an error 4 days? At this moment I am fed up of semi coloms!
Learning can be a lot of trial and error at the beginning. There was a lot of trial and error when I was learning PHP. I've learned to appreciate errors (sometimes I actually wish my code produced errors so I could figure out problems).
Link to post
Share on other sites
I know! But trial an error 4 days? At this moment I am fed up of semi coloms!
Here are a few hints to get help you get accustomed to them:semicolons( ; ) ----> In C syntax languages (C, C++, PHP, Java) semicolons are used to tell the interpreter/compiler (turns your code into machine instructions) that this is the end of a statement:
echo "Hello Web";

curly brackets({})----> These group statements into blocks, like your if,then, else blocks. You don't need to put a semicolon after a brace because the interpreter/compiler understands that this is a block.

//This wont work in Java but in Php it is legal{   echo "Hello Web";}

parenthesis(())----> Contain expressions which are evaluated for instance:

//(2+2) will be evaluated to 4 or true as it is not 0.

commas(,) ----> These separate variables like: var1, var2 ,var3 so you can operate on them together:

 var1,var2,var3 = var4;

Also don't frustrate yourself over the time it takes you to figure your code out. As the guys here have expressed over and over again developing and coding can't be mastered by rushing it all down at once. You need to take it piece by piece or you will choke. I appreciate this a lot because it happened to me when I started off.

Edited by sansana
Link to post
Share on other sites
You also use exclamation points a lot, it always looks like you're yelling at us. Get used to semicolons, you'll see them a lot in code. If you were actually selling your services doing this stuff, you would need to be able to find and fix basic errors like that. It's also time to get friendly with quotes, parentheses, square brackets, and curly brackets.
I´ll think about it! Yes, I don´t like them now because they cause me a lot of frustration! I don´t know if this will change!
Link to post
Share on other sites
Here are a few hints to get help you get accustomed to them:semicolons( ; ) ----> In C syntax languages (C, C++, PHP, Java) semicolons are used to tell the interpreter/compiler (turns your code into machine instructions) that this is the end of a statement:
echo "Hello Web";

curly brackets({})----> These group statements into blocks, like your if,then, else blocks. You don't need to put a semicolon after a brace because the interpreter/compiler understands that this is a block.

//This wont work in Java but in Php it is legal{   echo "Hello Web";}

parenthesis(())----> Contain expressions which are evaluated for instance:

//(2+2) will be evaluated to 4 or true as it is not 0.

commas(,) ----> These separate variables like: var1, var2 ,var3 so you can operate on them together:

 var1,var2,var3 = var4;

Also don't frustrate yourself over the time it takes you to figure your code out. As the guys here have expressed over and over again developing and coding can't be mastered by rushing it all down at once. You need to take it piece by piece or you will choke. I appreciate this a lot because it happened to me when I started off.

Thanks very much!
Link to post
Share on other sites
Learning can be a lot of trial and error at the beginning. There was a lot of trial and error when I was learning PHP. I've learned to appreciate errors (sometimes I actually wish my code produced errors so I could figure out problems).
Thanks very much!
Link to post
Share on other sites
I´ll think about it! Yes, I don´t like them now because they cause me a lot of frustration! I don´t know if this will change!
it better, because this part of learning to program. Programming languages are just what they are; languages. All languages have rules, structures, and ways of doing things that may differ between them, however it is just the way it is. Semi-colons and curly braces are just the basics. In a written language, that would be roughly equivalent to making sure you remembrer to punctuate. You still have to learn about nouns, verbs, and adjectives. As we've said this stuff doesn't come to people over night. It takes years to master anything, even a couple of years just to know it well. I know you are learning, but if you are going to stress yourself out during this process, you will offend people trying to help you and you will make the process even harder on yourself, at your own expense. This is the basics, learn it now and appreciate the errors, it's certainly better than having a blank screen and not knowing what was going on at all.
Link to post
Share on other sites
it better, because this part of learning to program. Programming languages are just what they are; languages. All languages have rules, structures, and ways of doing things that may differ between them, however it is just the way it is. Semi-colons and curly braces are just the basics. In a written language, that would be roughly equivalent to making sure you remembrer to punctuate. You still have to learn about nouns, verbs, and adjectives. As we've said this stuff doesn't come to people over night. It takes years to master anything, even a couple of years just to know it well. I know you are learning, but if you are going to stress yourself out during this process, you will offend people trying to help you and you will make the process even harder on yourself, at your own expense. This is the basics, learn it now and appreciate the errors, it's certainly better than having a blank screen and not knowing what was going on at all.
I think which I didn´t like (programming) I have to like! Also it´s a fact that I´ve learned a lot (about myself!)!
Link to post
Share on other sites

Frankly, if you don't like programming then you probably aren't going to be very successful at it. I've enjoyed programming since my first classes that taught it. Some things can get a little tedious but it's a creative activity, not just a job you do. It's the same with painting, for example. If you don't like painting, you're probably not going to be a very good painter.

Link to post
Share on other sites
Frankly, if you don't like programming then you probably aren't going to be very successful at it. I've enjoyed programming since my first classes that taught it. Some things can get a little tedious but it's a creative activity, not just a job you do. It's the same with painting, for example. If you don't like painting, you're probably not going to be a very good painter.
Philosophical.
Link to post
Share on other sites
Frankly, if you don't like programming then you probably aren't going to be very successful at it. I've enjoyed programming since my first classes that taught it. Some things can get a little tedious but it's a creative activity, not just a job you do. It's the same with painting, for example. If you don't like painting, you're probably not going to be a very good painter.
I totally agree with you! However, in life you have to make choices! You can´t do all the time what you like or you can´t always chose the girlfriend you first wish!For me could be a motivation that all problems have a solution (except death). Therefore I never give up! My great example is Jacques Anquetil (French ciclist ´50 previous century. When they said to him ´you can´t, he said ´I can´ and so I am! Edited by eduardchile
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...