eduard Posted February 17, 2011 Share Posted February 17, 2011 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> Link to comment Share on other sites More sharing options...
Squalus12 Posted February 17, 2011 Share Posted February 17, 2011 Are you getting any errors when you run this? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 17, 2011 Share Posted February 17, 2011 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()); Link to comment Share on other sites More sharing options...
thescientist Posted February 17, 2011 Share Posted February 17, 2011 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. Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 Are you getting any errors when you run this?No Link to comment Share on other sites More sharing options...
boen_robot Posted February 17, 2011 Share Posted February 17, 2011 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!!! Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 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??? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 17, 2011 Share Posted February 17, 2011 I suggest you add the error checking code I showed in post 3. Link to comment Share on other sites More sharing options...
thescientist Posted February 17, 2011 Share Posted February 17, 2011 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? Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 I suggest you add the error checking code I showed in post 3.There is no error! Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 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! Link to comment Share on other sites More sharing options...
justsomeguy Posted February 17, 2011 Share Posted February 17, 2011 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. Link to comment Share on other sites More sharing options...
thescientist Posted February 17, 2011 Share Posted February 17, 2011 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? Link to comment Share on other sites More sharing options...
boen_robot Posted February 17, 2011 Share Posted February 17, 2011 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 createdorError creating database: Can't create database 'my_db'; database existsDoes it? Try it! Link to comment Share on other sites More sharing options...
thescientist Posted February 17, 2011 Share Posted February 17, 2011 but he could also just tell us if he's sees anything in phpMyAdmin too... Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 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! Link to comment Share on other sites More sharing options...
ShadowMage Posted February 17, 2011 Share Posted February 17, 2011 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) Link to comment Share on other sites More sharing options...
boen_robot Posted February 17, 2011 Share Posted February 17, 2011 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. - icon for topic that is closed. - 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] Link to comment Share on other sites More sharing options...
ShadowMage Posted February 17, 2011 Share Posted February 17, 2011 There will also be a image in place of the "add reply" button at the beginning and end of the thread when you are reading a closed thread. Link to comment Share on other sites More sharing options...
thescientist Posted February 17, 2011 Share Posted February 17, 2011 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. Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 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!) Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 Two things:1. thescientist is not a moderator. He's just a frustrated forum member (like all of us).2. - icon for topic that is closed. - icon for "hot" (in other words - "popular") topic in which you have posted.Ok, thanks! Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 There will also be a 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! Link to comment Share on other sites More sharing options...
thescientist Posted February 17, 2011 Share Posted February 17, 2011 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. Link to comment Share on other sites More sharing options...
eduard Posted February 17, 2011 Author Share Posted February 17, 2011 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? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.