Storing PHP in Text field Problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
crump
Forum Newbie
Posts: 6
Joined: Tue May 13, 2003 7:04 pm

Storing PHP in Text field Problem

Post by crump »

What i want to do is store php/html code in a text field and recall it later and place it in different tables across the screen. So using phpMyAdmin I created a table named "tables" and added 4 fields

pane_id-mediumint(9),
pane_info-test,
pane_name-varchar(20),
pane_location-mediumint(9)

Now i can't access the table with:

Code: Select all

<?php
<?php

$linkID = mysql_connect("localhost","username","password");
if ($linkID != false){print "The connection to the CLAN has been made";}
else{print "No connection dumb @ss";}

$dbID = mysql_select_db("CLAN", $linkID);
if ($dbID != FALSE){print"Connected to DB";}

$resultID =  ("SELECT * FROM table, $linkID");
if ($resultID != FALSE){print "okay";}
else{print "doh!";}
?>
?>
This is the only thing in the file and the error i get is:
It comes back saying that the query was unsuccessful "doh!"
I've tried searching these forums and looking at all the tutorials but it always seems this part gets left out cause it is so simple.

Finally once i'm finally able to access this file can I use something like this to hold the information:

Code: Select all

for ($tableNum = 0; $tableNum < mysql_num_rows($resultID) ; $tableNum++){
list($pane_id,$pane_info,$pane_name,$pane_location)=mysql_fetch_row($result);

//put in the rest of code here
Am I on the right track?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

$resultID = ("SELECT * FROM table, $linkID");
you have one string but the connectionId is not part of the first parameter, it's a second (optional) argument.
you have to pass this query to mysql

Code: Select all

// this is only a string literal stored in a variable, mysql doesn't know anything about it
$resultID =  "SELECT * FROM table";
try

Code: Select all

$resultID =  mysql_query('SELECT * FROM table', $linkID);
Am I on the right track?
definitly, go on ;)
crump
Forum Newbie
Posts: 6
Joined: Tue May 13, 2003 7:04 pm

Post by crump »

I'm sorry when i cut and pasted it must have left that out. What i have is

Code: Select all

<?php

$linkID = mysql_connect("localhost","username","password");
if ($linkID != false){print "The connection to the CLAN has been made";}
else{print "No connection dumb ass";}

$dbID = mysql_select_db("CLAN", $linkID);
if ($dbID != FALSE){print"Connected to DB";}

$resultID =  mysql_query('SELECT * FROM table', $linkID);
if ($resultID != FALSE){print "okay";}
else{print "doh!";}

?>
And what i get in return is:
The connection to the CLAN has been madeConnected to DBdoh!
I've used this method for a lot of other tables and the only difference with this table is that is has a text field in it. I want to store php/html code in a text field, but i can't access it. :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I think that the problem might be the table name:
http://www.mysql.com/doc/en/Reserved_words.html

Mac
crump
Forum Newbie
Posts: 6
Joined: Tue May 13, 2003 7:04 pm

Post by crump »

Wow, Thank you :) That was it!
Post Reply