• Announcements

    • boen_robot

      Guidelines and Netiquette   03/28/2017

      Posting Problems:   Having problems posting your topic? Read through this: To join, you agree to our terms and conditions and fill out and submit a registration form. An activation email will be sent to your email adress, so you'll need to verify your account. After that the account has to be validated by one of the moderators. This will mean that it can take up to a day to be activated. A couple of things to remember to ensure approval: Don't use an email address in one of those $2 four character .com domains eg. xyds.com. These will be deleted and the domain added to the banned list. Don't use an email address that is within a domain with a bad reputation for spam. A Google search is run on every email address and email domain. Don't sign up with an email address that doesn't exist, doesn't work or requires the sender to answer a quiz before their email can get to you. Put your country and or state and city in the signup form. Blank forms will go to the botton of the "to do" list. And make sure that your email address and your country match, saying you're from Alabama and using a .ru email address is not going to get you activated. After a membership is activated the first few posts will be monitored. Posting spam or unapproved topics described in the agreement results in an immediate ban. The email provider and the IP addresses associated with the account will be banned and all posts will be deleted. These strict measures have been deemed necessary to hinder spam. Sorry for any inconvenience this causes, but it's not liable to change. If, after reading this, you still can't post and don't understand why, contact one of the Moderators listed here.   Topic Guidelines   Including the following information can expedite an accurate response from board members: Must be a Specific Problem or Question related to web design and development Include Code in Question (wrap with   for small blocks of code and for longer blocks   ) Include Code Author Include Extra Notes/Modifications/Attempts Include web link to page/file when possible Content Guidelines   You may not post, upload, link to, or email any Content that contains, promotes, gives instruction about, or provides prohibited Content. Prohibited Content includes any Content that breaks any local, state, county, national or international law. Prohibited Content also includes: No direct or indirect advertising or websites, forums, products, services No hijacking of posts (do not post your question in someone elses) Content that infringes upon any rights [ex. MP3s and ROMs] (including, but not limited to, copyrights and trademarks) Abusive, threatening, defamatory, racist, or obscene Viruses or any other harmful computer software False Information or libel Spam, chain letters, or Pyramid schemes Gambling or Illicit drugs Terrorism Hacking or cheating for internet/online games Warez, Roms, CD-Keys, Cracks, Passwords, or Serial Numbers Pornography, nudity, or sexual material of any kind Excessive profanity Invasive of privacy or impersonation of any person/entity Hacking materials or information Posting Tips   There are more BBcodes than there are buttons for on the reply menu. To get the full list, click "BB Code Help" underneath the clickable smilie face menu. Use   for small snippets of code Use   for lengthy snippets of code Use   if your snippet is HTML (optional) Use   if your snippet is SQL (optional) Rules of Conduct   Be nice. There's no need for calling someone stupid if they ask an 'easy' question. Keep your avatars and signatures absolutely child friendly. We have a younger audience on this forum. Keep your language appropriate for the same reason above. Do not PM moderators for help on the forum. Post on the topic, or create a new one.   Spam:   Recently, as you have all without doubt noticed, we have had lots of spam and advertisement on the forum. Therefore, we'd like to alert you as to what to do when you have found any of the aforementioned annoying messages: it. Immediately. Give a clear reason, please, if the advertising is not evident. DO NOT POST! Report, let the post stay as is, and we will get to it, meanwhile if you continue to post as normal in the other threads, it won't be on the top so long. Refrain from PMing the member. This won't help at all, as they are most likely spambots anyway. Thank you.       Images in signatures:   After thinking of users on dial-up, we have decided to enforce the following rules regarding signatures. Please pay heed to them. Respecting these rules is respecting the members on this forum with dial-up. Signature rules: No animated images AT ALL. No matter the amount of animation. Maximum image widthxheight: 300x150 Maximum image (file) size: 15kb Use calm colors. Do not use highly contrasting images in your signature, as this can get really annoying when seeing several posts from one member in the same thread. The same prohibited content goes for images as for posts. Lastly, use common sense. No lengthy signatures please. Save us some scrolling. Thank you.       Links in signatures:   Please understand that w3schools.com only exists because of voluntary work and is barely supported by the advertising littered throughout the tutorials and the forum. So, please, stop advertising other sites. DO not post links that drive traffic away from the w3schools domain - especially to a site that offers similar if not identical information. Please help support the site by keeping individuals on it. Thank you. Here are some guidelines as to what you can put in your signature: w3schools links --> allowed w3.org links --> allowed browser links --> allowed html editor links --> allowed personal sites --> allowed tutorial sites competing with w3schools --> NOT allowed sites completely irrelevant to webprogramming and this forum --> NOT allowed   Thanks for understanding, and for taking the time to read this. ~W3Schools Modstaff~
eduard

Table?

166 posts in this topic

I still can´t create a table! And I never got an answer to the question: my "my-db" must be a php file?Code:<html><body><?php$con = mysql_connect("localhost","eduard");if (!$con){die ('Could not connect: ' . mysql_error());}// Create databaseif (mysql_query ("CREATE DATABASE my_db",$con)){echo "Database created";}else{echo "Error creating database: " . mysql_error();}// Create tablemysql_select_db("my_db", $con);$sql = "CREATE TABLE Persons"{FirstName varchar (15),LastName varchar (15),Age int}";// Execute querymysql_query($sql,$con);mysql_close($con);?></body></html>

Edited by eduardchile

Share this post


Link to post
Share on other sites

I don't know what your "my-db" is, but if you're talking about the database, no, a database is not a PHP file.You're not checking for errors when you try to create the table, you should check if the query failed and print an error message if it did.mysql_query($sql,$con) or exit(mysql_error());

Share this post


Link to post
Share on other sites

good lord, do you even read anything we tell you? At all? Even just a little bit?First off, you're not using root as the username. Unless you specifically changed it in the configuration file, then this will not work. It should be quite simple. Can you even just get it to display a connection successful message? Drop the table code and just work at just getting step one to work.Also, we've had a whole thread discussing the relationship between PHP and SQL. The main point being other than PHP allowing you to connect to a database, there IS NO intrinsic relationship.And lastly, I'm not sure how long you plan on doing this, but keep your topics distinct! This IS STILL THE SAME ISSUE! You are hogging up all the space in this forum by asking the same question repeatedly, and thus cluttering up the forum with your threads while other users are actually trying to follow the rules. Its cluttering up the database and detracting from other users who are posting legitimate topics of unique distinction. You may not realize it but this is borderline selfish behavior. Moderators and members alike have brought this issue up before, not just myself. So follow the rules, and just bump your own threads. It's not like we're not trying to help, but give us a reason. Right now there might as well be a brick wall on the other end, and you're only doing yourself a disservice by not listening to our repeated pleas to engage in proper forum etiquette.phew.

Share this post


Link to post
Share on other sites
Are you getting any errors when you run this?
No

Share this post


Link to post
Share on other sites

Try to do this one step at a time...

<?php$con = mysql_connect("localhost","root", "");if (!$con){die ('Could not connect: ' . mysql_error());}echo "Database connection estabilished.";?>

What does this output? It needs to output

Database connection estabilished.
Does it? Try it!!!

Share this post


Link to post
Share on other sites
good lord, do you even read anything we tell you? At all? Even just a little bit?First off, you're not using root as the username. Unless you specifically changed it in the configuration file, then this will not work. It should be quite simple. Can you even just get it to display a connection successful message? Drop the table code and just work at just getting step one to work.Also, we've had a whole thread discussing the relationship between PHP and SQL. The main point being other than PHP allowing you to connect to a database, there IS NO intrinsic relationship.And lastly, I'm not sure how long you plan on doing this, but keep your topics distinct! This IS STILL THE SAME ISSUE! You are hogging up all the space in this forum by asking the same question repeatedly, and thus cluttering up the forum with your threads while other users are actually trying to follow the rules. Its cluttering up the database and detracting from other users who are posting legitimate topics of unique distinction. You may not realize it but this is borderline selfish behavior. Moderators and members alike have brought this issue up before, not just myself. So follow the rules, and just bump your own threads. It's not like we're not trying to help, but give us a reason. Right now there might as well be a brick wall on the other end, and you're only doing yourself a disservice by not listening to our repeated pleas to engage in proper forum etiquette.phew.
Sorry, but step 1 (connection is working some days, I removed "localhost" and "eduard" and I know since 6 hours that there is no relatinship BUT I still haven´t a table!Code:<html><body><?php$con = mysql_connect;if (!$con){die ('Could not connect: ' . mysql_error());}// Create databaseif (mysql_query ("CREATE DATABASE my_db",$con)){echo "Database created";}else{echo "Error creating database: " . mysql_error();}// Create tablemysql_select_db("my_db", $con);$sql = "CREATE TABLE Persons"{FirstName varchar (15),LastName varchar (15),Age int}";// Execute querymysql_query($sql,$con);mysql_close($con);?></body></html>P. s. if you close the thread, how can I react??? Edited by eduardchile

Share this post


Link to post
Share on other sites

I suggest you add the error checking code I showed in post 3.

Share this post


Link to post
Share on other sites

just for future references sake, you should still leave some place holder for those values, or else people will think your getting the connection part wrong. just replace the characters with * instead. People will understand the intent.Do you know you're not making a table because you are relying on a feedback message from your script? Or are you verifying in phpMyAdmin? One obvious mistake in the code is that you are using curly braces instead of parenthesis. You can just follow the convention from the DB connect part to show a message.

// Create tablemysql_select_db("my_db", $con);$sql = "CREATE TABLE Persons"(FirstName varchar (15),LastName varchar (15),Age int)";// Execute queryif(mysql_query($sql,$con)){  echo 'table made.';  //check phpMyAdmin to confirm}else{  echo 'error, table not made';};

edit: no one said anything about closing a thread, but you're making it harder for other people to get their threads seen, you spreading out the same questions over multiple topics, making it harder for people to help you and keep information centralized, and you're making more work for the mods because they will end up merging your threads together because of the similarities. I don't think it's asking to much to keep your own threads organized and updated. You said yourself you find it confusing to keep track of posts and replies. How does making multiple threads about the same subject do anything to alleviate that burden on yourself?

Edited by thescientist

Share this post


Link to post
Share on other sites
I suggest you add the error checking code I showed in post 3.
There is no error!

Share this post


Link to post
Share on other sites
Try to do this one step at a time...
<?php$con = mysql_connect("localhost","root", "");if (!$con){die ('Could not connect: ' . mysql_error());}echo "Database connection estabilished.";?>

What does this output? It needs to outputDoes it? Try it!!!

Connection is not my question (I have connection) BUT I haven´t yet a table!

Share this post


Link to post
Share on other sites
There is no error!
So you added the code I told you to add, ran the page, and didn't see an error. If that's true, then it created the table. With the code I told you to add, if it failed creating the table then you would have seen an error. So congratulations, you made a table. If you refresh the page you should see an error due to the fact that the table already exists, you can't create it again.

Share this post


Link to post
Share on other sites

and as I've pointed out (again and again... :)) you can verify in phpMyAdmin....edit: just for sticks giggles, what does your code look like now?

Edited by thescientist

Share this post


Link to post
Share on other sites

One... f**king... step... at a time...The reason is never the place you have a problem with itself - the reason is always something before or during the thing that's supposed to make it.OK... if my previous example above is working, try this:

<?php$con = mysql_connect("localhost","root", "");if (!$con){die ('Could not connect: ' . mysql_error());}if (mysql_query("CREATE DATABASE my_db",$con)){echo "Database created";}else{echo "Error creating database: " . mysql_error();}?>

What does that output? It should output either

Database created
or
Error creating database: Can't create database 'my_db'; database exists
Does it? Try it!

Share this post


Link to post
Share on other sites

but he could also just tell us if he's sees anything in phpMyAdmin too...

Edited by thescientist

Share this post


Link to post
Share on other sites
just for future references sake, you should still leave some place holder for those values, or else people will think your getting the connection part wrong. just replace the characters with * instead. People will understand the intent.Do you know you're not making a table because you are relying on a feedback message from your script? Or are you verifying in phpMyAdmin? One obvious mistake in the code is that you are using curly braces instead of parenthesis. You can just follow the convention from the DB connect part to show a message.
// Create tablemysql_select_db("my_db", $con);$sql = "CREATE TABLE Persons"(FirstName varchar (15),LastName varchar (15),Age int)";// Execute queryif(mysql_query($sql,$con)){  echo 'table made.';  //check phpMyAdmin to confirm}else{  echo 'error, table not made';};

edit: no one said anything about closing a thread, but you're making it harder for other people to get their threads seen, you spreading out the same questions over multiple topics, making it harder for people to help you and keep information centralized, and you're making more work for the mods because they will end up merging your threads together because of the similarities. I don't think it's asking to much to keep your own threads organized and updated. You said yourself you find it confusing to keep track of posts and replies. How does making multiple threads about the same subject do anything to alleviate that burden on yourself?

I don´t understand your first part (connection)! and what does a red ? before a thread mean? I thought topic is closed (by you), but it seems it isn´t Therefore it´sn´t necessary for me indeed to post the same thread twice!

Share this post


Link to post
Share on other sites
what does a red ? before a thread mean? I thought topic is closed (by you), but it seems it isn´t Therefore it´sn´t necessary for me indeed to post the same thread twice!
I have never seen a red question mark before a thread.... :) Are you by chance referring to the red breifcase icon? That just means that the topic is "popular" (ie, it has 14 or more replies in it)

Share this post


Link to post
Share on other sites
and what does a red ? before a thread mean? I thought topic is closed (by you), but it seems it isn´t Therefore it´sn´t necessary for me indeed to post the same thread twice!
Two things:1. thescientist is not a moderator. He's just a frustrated forum member (like all of us).2.f_closed.gif - icon for topic that is closed.f_hot_no_dot.gif - icon for "hot" (in other words - "popular") topic in which you have posted.[edit]BTW, I think that'a "red folder", not a "red briefcase"[/edit]

Share this post


Link to post
Share on other sites

There will also be a t_closed.gif image in place of the "add reply" button at the beginning and end of the thread when you are reading a closed thread.

Edited by boen_robot
And just for the record, ShadowMage is also not a moderator, and the topic is still open.

Share this post


Link to post
Share on other sites
I don´t understand your first part (connection)! and what does a red ? before a thread mean? I thought topic is closed (by you), but it seems it isn´t Therefore it´sn´t necessary for me indeed to post the same thread twice!
Sigh... the point is that THIS thread is a repeat of OTHER threads you have made about this kind of topic, and some of those threads are duplicates or very very similar to OTHER topics you have made. (heck the titles are pretty much identical....) Which is why the moderators have closed some of your other threads. (with a red x next to it)What about "connection" don't you understand? I'm not sure what you mean. My code snippet was just a way to add feedback messaging to the create process, like JSG suggested, and what was also being done for the database creation. It was meant to tell you if the table was created or not. If you don't understand something, please provide specifics on the issue and the part you don't get. Edited by thescientist

Share this post


Link to post
Share on other sites
I have never seen a red question mark before a thread.... :) Are you by chance referring to the red breifcase icon? That just means that the topic is "popular" (ie, it has 14 or more replies in it)
Thanks! (? or icon!)

Share this post


Link to post
Share on other sites
Two things:1. thescientist is not a moderator. He's just a frustrated forum member (like all of us).2.f_closed.gif - icon for topic that is closed.f_hot_no_dot.gif - icon for "hot" (in other words - "popular") topic in which you have posted.
Ok, thanks!

Share this post


Link to post
Share on other sites
There will also be a t_closed.gif image in place of the "add reply" button at the beginning and end of the thread when you are reading a closed thread.
Ok, thanks!

Share this post


Link to post
Share on other sites

also, when you are in a subform (like the PHP forum) if you scroll down to the bottom of the page you will see legend for all the forums icon's and what they mean.

Edited by thescientist

Share this post


Link to post
Share on other sites

I am still not able to create a table (connection is ok!)!Code:<html><body><?php$con = mysql_connect;if (!$con){die ('Could not connect: ' . mysql_error());}// Create databaseif (mysql_query ("CREATE DATABASE my_db",$con)){echo "Database created";}else{echo "Error creating database: " . mysql_error();}// Create tablemysql_select_db("my_db", $con);$sql = "CREATE TABLE Persons"{FirstName varchar (15),LastName varchar (15),Age int}";// Execute queryif(mysql_query($sql,$con)){ echo 'table made'; //check phpMyAdmin to confirm}else{ echo 'error, table not made';};mysql_close($con);?></body></html>Who knows why?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now