Return to iWEBTOOL

Go Back   iWEBTOOL Talk > The Web and your Website > Programming > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
Welcome to iWEBTOOL Talk, where you talk about webmaster-related stuff.
 
Discuss topics which interest you.
With over thousands of threads (topics), we're sure you'll find something that'll interest you.
Ask for help whenever you need it.
We have thousands of members who are available to help you if you need it.
It's absolutely FREE!

 1  Register           2  Browse the board           3  Discuss whatever may interest you!
 


Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 07-10-2006, 04:47 AM   #1
jumpenjuhosaphat
 Contributor 
 
jumpenjuhosaphat's Avatar
 
Join Date: Jun 2006
Location: Denver
Posts: 4,459
jumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud of
Default MySql

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".
__________________
Storage Sheds
Lost Forum
jumpenjuhosaphat is offline  
 
This is an Ad Revenue Sharing forum Place your advert here
SEO Checklist
Get yourself better ranking with
our "Do-it-Yourself" SEO Checklist.
Click Here
Old 07-10-2006, 07:22 AM   #2
jumpenjuhosaphat
 Contributor 
 
jumpenjuhosaphat's Avatar
 
Join Date: Jun 2006
Location: Denver
Posts: 4,459
jumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud of
Default Re: MySql

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?
__________________
Storage Sheds
Lost Forum
jumpenjuhosaphat is offline  
Old 07-10-2006, 08:37 AM   #3
rohan2kool
Member
 
rohan2kool's Avatar
 
Join Date: Dec 2005
Posts: 132
rohan2kool will become famous soon enough
Default Re: MySql

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.
rohan2kool is offline  
Old 07-10-2006, 04:09 PM   #4
Daniel Malone
Senior Member
 
Daniel Malone's Avatar
 
Join Date: May 2006
Posts: 252
Daniel Malone will become famous soon enough
Default Re: MySql

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
Daniel Malone is offline  
Old 07-10-2006, 05:18 PM   #5
jumpenjuhosaphat
 Contributor 
 
jumpenjuhosaphat's Avatar
 
Join Date: Jun 2006
Location: Denver
Posts: 4,459
jumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud of
Default Re: MySql

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.
__________________
Storage Sheds
Lost Forum
jumpenjuhosaphat is offline  
Old 07-10-2006, 05:33 PM   #6
jumpenjuhosaphat
 Contributor 
 
jumpenjuhosaphat's Avatar
 
Join Date: Jun 2006
Location: Denver
Posts: 4,459
jumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud of
Default Re: MySql

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.
jumpenjuhosaphat is offline  
Old 07-10-2006, 10:04 PM   #7
jumpenjuhosaphat
 Contributor 
 
jumpenjuhosaphat's Avatar
 
Join Date: Jun 2006
Location: Denver
Posts: 4,459
jumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud ofjumpenjuhosaphat has much to be proud of
Default Re: MySql

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?
__________________
Storage Sheds
Lost Forum
jumpenjuhosaphat is offline  
 
This is an Ad Revenue Sharing forum Place your advert here
Webmaster Tools Webmaster Tools Click Here
Closed Thread

(Threads which have no activity for more than 30 days are automatically closed.)



Quick Reply
Message:

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Common PHP/MySQL Procedures compuXP MySQL 13 01-30-2008 09:28 PM
Website Content Databases - MySQL & MS Access odditysoftware Websites for Sale 115 11-28-2006 09:19 PM
MSSQL or MySQL? loon Web Hosting 3 11-20-2006 10:43 AM
Remotely Accessing MySQL Database? compuXP MySQL 4 08-31-2006 05:05 AM


All times are GMT. The time now is 12:22 AM.


Powered by vBulletin v3.6.7 © 2008, Jelsoft Enterprises Ltd. SEO by vBSEO © 2006, Crawlability, Inc.