Page 1 of 1

Storing PHP in Text field Problem

Posted: Wed May 14, 2003 7:51 pm
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?

Posted: Thu May 15, 2003 12:38 am
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 ;)

Posted: Thu May 15, 2003 12:15 pm
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. :)

Posted: Thu May 15, 2003 1:44 pm
by twigletmac
I think that the problem might be the table name:
http://www.mysql.com/doc/en/Reserved_words.html

Mac

Posted: Thu May 15, 2003 4:14 pm
by crump
Wow, Thank you :) That was it!