I'm trying to create a blog-type thing where certian members I choose can add their entries, but I was wondering if anyone knows how to grab their username and an icon they select from the membership database, then insert it, along with their entries, into a second database. Here's what I have so far:
<?php
$hostname='host';
$user='user'; //'user name for MySQL database';
$pass='ps'; //'Password for database';
$dbase='db'; //'database name';
$connection = mysql_connect("$hostname" , "$user" , "$pass");
// Check if user submit blank entry
if ($entry == '' || $title == '')
{
die ('You must fill in all fields, please click back and try again.');
}
else {$q="insert into review (id,title,date,entry) VALUES ('','$title',now()),'$entry'";
$result = mysql_query($q,$connection);
if ($result)
{
echo "Thank you! Your review should display on the site within a week!";
}
}
?>
Anyone know the code I need, or know where I can get it?only if you have access to the database. you have to have the user/pass for the other database. if so then just do a query on that database and grab the info.
but I see on this code you have you do not select the database you are connecting to as it is.
$db = mysql_select_db($dbase);
$db2 = mysql_select_db("second_db");
than on each query you can give it what database to grab info from.
$result = mysql_query($q,$db);
$result = mysql_query($q,$db2);Oh oops! Sorry, I think It was late at night and I was kinda delerious when I wrote that... What I meant was... well, the information is actually all in the same database, just two different tables. I wanted to read the current user's username and icon (which are both in the 'membership' table) from a cookie, or something like that. Sorry, I'm a little new and I don't have a ton of experience with PHP and MySQL. :doh: But thank you for your answer anyway...well then I have no idea what you want. can you explain it again?Yeah, I'm really sorry about this. I'm horrible at explaining things... :monkey:
OK, basically, I have a form which includes a cookie check so only certain members can go to it. What I want to do is read the username and icon URL from the cookie and instert it into the review table, like it does to the left of the entry in these forums...ok, how did they get the cookie? if you set a cookie from a database tehn why not have that info in that one, why write to another one?
<?php
$hostname='host';
$user='user'; //'user name for MySQL database';
$pass='ps'; //'Password for database';
$dbase='db'; //'database name';
$connection = mysql_connect("$hostname" , "$user" , "$pass");
// Check if user submit blank entry
if ($entry == '' || $title == '')
{
die ('You must fill in all fields, please click back and try again.');
}
else {$q="insert into review (id,title,date,entry) VALUES ('','$title',now()),'$entry'";
$result = mysql_query($q,$connection);
if ($result)
{
echo "Thank you! Your review should display on the site within a week!";
}
}
?>
Anyone know the code I need, or know where I can get it?only if you have access to the database. you have to have the user/pass for the other database. if so then just do a query on that database and grab the info.
but I see on this code you have you do not select the database you are connecting to as it is.
$db = mysql_select_db($dbase);
$db2 = mysql_select_db("second_db");
than on each query you can give it what database to grab info from.
$result = mysql_query($q,$db);
$result = mysql_query($q,$db2);Oh oops! Sorry, I think It was late at night and I was kinda delerious when I wrote that... What I meant was... well, the information is actually all in the same database, just two different tables. I wanted to read the current user's username and icon (which are both in the 'membership' table) from a cookie, or something like that. Sorry, I'm a little new and I don't have a ton of experience with PHP and MySQL. :doh: But thank you for your answer anyway...well then I have no idea what you want. can you explain it again?Yeah, I'm really sorry about this. I'm horrible at explaining things... :monkey:
OK, basically, I have a form which includes a cookie check so only certain members can go to it. What I want to do is read the username and icon URL from the cookie and instert it into the review table, like it does to the left of the entry in these forums...ok, how did they get the cookie? if you set a cookie from a database tehn why not have that info in that one, why write to another one?