PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
orbdrums
Forum Commoner
Posts: 82 Joined: Wed Sep 14, 2011 11:42 pm
Post
by orbdrums » Wed Oct 26, 2011 10:57 pm
Hi all,
The following code is giving me fits. I'm sure it's my syntax that is incorrect but I don't know where. Any help would be greatly appreciated.
Code: Select all
<?php
$query_users = "SELECT * FROM Users.members";
$result = mysql_query($query_users);
$r_n = 1;
while ($row = mysql_fetch_assoc($result))
{
$mbr_log = $row[`login`];
echo $r_n," ",$row['login'],"<br />";
[color=red]mysql_query("CREATE TABLE Contacts.'$mbr_log' SELECT * FROM Contacts.AB_Macbook")[/color]
//echo " ";
//echo "<td>",$row['login_time'];
//echo " ";
$r_n++;
}
?>
orbdrums
Forum Commoner
Posts: 82 Joined: Wed Sep 14, 2011 11:42 pm
Post
by orbdrums » Wed Oct 26, 2011 11:05 pm
The span tag in my first post doesn't exist in my code. It was put in by this site when I tried to change the font color of the suspect line of code to red. Here is my code:
Code: Select all
<?php
$query_users = "SELECT * FROM Users.members";
$result = mysql_query($query_users);
$r_n = 1;
while ($row = mysql_fetch_assoc($result))
{
$mbr_log = $row[`login`];
echo $r_n," ",$row['login'],"<br />";
mysql_query("CREATE TABLE Contacts.'$mbr_log' SELECT * FROM Contacts.AB_Macbook")
//echo " ";
//echo "<td>",$row['login_time'];
//echo " ";
$r_n++;
}
?>
</body>
Dodon
Forum Commoner
Posts: 64 Joined: Wed Aug 03, 2011 4:11 am
Location: Netherlands
Post
by Dodon » Thu Oct 27, 2011 8:35 am
Not sure if it matters but
doesn't have proper single quotes.
Second you don't need the single quotes in the query, if I try the query directly in phpmyadmin it complains about the singlequote so try:
Code: Select all
mysql_query("CREATE TABLE Contacts.$mbr_log SELECT * FROM Contacts.AB_Macbook");
Also your query was missing a
; at the end of the line