|
| |||||||
![]() | Welcome to iWEBTOOL Talk, where you talk about
webmaster-related stuff.
1 Register
2 Browse the board
3 Discuss whatever may interest you! | |||||||||||||
![]() |
| | Thread Tools | Search this Thread | Display Modes |
| | #1 |
| Contributor Join Date: Jun 2006 Location: Denver
Posts: 4,459
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | They said sql would be easier to learn than HTML, CSS, and PHP. But so far, it's been nothing but a head ache. I got the last problem figured out, NOW.....I cant get the mysql_query construct to NOT take varibles literally. I am trying to create a table, named xwhateverx, xwhateverx is stored in a variable that was given by the user in a form, but instead of creating a table named xwhateverx, it creates on called $variable. Here is the script. Dang, I can't paste in this window ![]() Well, I know the body of the construct is okay, so here is the part of the script I am having trouble with: mysql_query("CREATE TABLE $thisandthat (' it literally creates a table named "$thisandthat". |
| |
|
| |||||||
| | #2 |
| Contributor Join Date: Jun 2006 Location: Denver
Posts: 4,459
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Okay, so I did 3000 tests, and I finally realized that mysql_query(CREATE TABLE whatever (jobo VARCHAR(30)); won't even create a table. I got it to create tables before, but now, no table at all. Every time I enter a name into the form field, it adds it to another table, like it's supposed to do, but then I call this line, and nothing, nothing at all, no table, no nothing. I looked at all of the tutorials, and forums, and whatnot I could find, and this matches everything I saw so far. Did I lock out the ability to create a table from within PHP or something? |
| |
| | #3 |
| Member Join Date: Dec 2005
Posts: 132
![]() | it should be: $conn = mysql_connect("localhost", "root", ""); $rs = mysql_select_db("your_database_name", $conn); $rs = mysql_query("create table whatever(jobo varchar(30))"); You need to connect and select the database earlier. And you're not using complete SQL, it's more like SQL from within php ![]()
__________________ Eat healthy, Stay Fit, Die Anyway. --==-- If there is a man who knows everything about women, there is a Windows distribution without bugs. |
| |
| | #4 |
| Senior Member Join Date: May 2006
Posts: 252
![]() | jumpenjuhosaphat, When you post something, it would be more helpful if you were to pos the entire script, because sometimes the problem is somewhere else in the script, like this. And yes, you need to connect to your MySQL database. BTW, download phpMyAdmin.
__________________ Webmaster News and Daniel's blog can be found at Daniel Malone Free Webmaster Tools |
| |
| | #5 |
| Contributor Join Date: Jun 2006 Location: Denver
Posts: 4,459
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | pypmyadmin is included with my version of MySql. Thats how I was checking to see if the table was being created. I did connect to the data base: $dbh=mysqul_connect(stuff, things, morestuff) or die(evenmorestuff) then: mysql_select_db(database) then: mysql_query(INSERT INTO stuff) which works fine then: $sql="(CREATE TABLE stuff (field one VARCHAR(10), field two VARCHAR(10))"; then; mysql-query($sql, $dbh); If it would help, I can post the exact script on a web page so you could see it and give you the address, but I can't seem to paste inside of this text box. I tried alot of variations of the above, including assigning each to variables, like you mentioned, I even used MySqlAdmin to create the PHP for me, and still, didn't do anything. |
| |
| | #6 |
| Contributor Join Date: Jun 2006 Location: Denver
Posts: 4,459
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Okay, here's where to view the script: http://hotactress.buyyourgadgets.com/stuff.bbb There is a simple form used to inject a name into the php script, and that works fine. I placed an echo statement at the end which echos the contents of $dbh and $sql. I did this to make sure that they contained the correct information, and as far as I can tell, they did. Last edited 07-10-2006 at 05:36 PM. |
| |
| | #7 |
| Contributor Join Date: Jun 2006 Location: Denver
Posts: 4,459
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Okay, I figured it out. I was entering two(2) names, first and last, into the field, which works fine in a table cell, but not in a table name. Thats why it would enter the name in the existing table, but not create a new one. Next problem is, how do I fill any spaces in with an underscore? Anyone want to tackle that one? |
| |
(Threads which have no activity for more than 30 days are automatically closed.) |
| Quick Reply | ||
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Common PHP/MySQL Procedures | compuXP | MySQL | 13 | 01-30-2008 08:28 PM |
| Website Content Databases - MySQL & MS Access | odditysoftware | Websites for Sale | 115 | 11-28-2006 08:19 PM |
| MSSQL or MySQL? | loon | Web Hosting | 3 | 11-20-2006 09:43 AM |
| Remotely Accessing MySQL Database? | compuXP | MySQL | 4 | 08-31-2006 05:05 AM |