•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 402,095 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,467 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 353 | Replies: 5
![]() |
i am adding elements to my db and the elemtents which have been add will be displayed on a different page. i am using an upload page which creates a thumb nail of an uploaded image and then stores the path for this image in a variable called $thumb_name. the code i have used to enter the image into the db is
and the code to display the image on the next page looks like this
php Syntax (Toggle Plain Text)
include "db.php"; $con = mysql_pconnect("$dbhost","$dbusername","$dbpasswd") or die ("QUERY ERROR: ".mysql_error()); $db = mysql_select_db("$database_name", $connection) or die("QUERY ERROR: ".mysql_error()); // Create table in $database_name database mysql_select_db("$database_name", $connection); $sql = "CREATE TABLE images (imageID int NOT NULL AUTO_INCREMENT, Broad1 varchar(50), Broad2 varchar(50), Broad3 varhar(50))"; mysql_query("INSERT INTO images (Broad1) VALUES ('$thumb_name')"); ?>
and the code to display the image on the next page looks like this
php Syntax (Toggle Plain Text)
<?php include"db.php"; $result = mysql_query("SELECT * FROM images WHERE 'Broad1'='$thumb_name'"); { echo $row['Broad1']; echo "<br />"; } ?>
Last edited by peter_budo : Mar 18th, 2008 at 6:11 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
Everything is correct.. But this is wrong.
This should be
•
•
•
•
$result = mysql_query("SELECT * FROM images WHERE 'Broad1'='$thumb_name'");
{
echo $row['Broad1'];
echo "<br />";
}
?>
php Syntax (Toggle Plain Text)
$result = mysql_query("SELECT * FROM images WHERE 'Broad1'='$thumb_name'"); $row= mysql_fetch_array($result); echo $row['Broad1']; echo "<br />"; ?>
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Dec 2007
Posts: 112
Reputation:
Rep Power: 1
Solved Threads: 13
And
Should be
No quotes around Broad1.
php Syntax (Toggle Plain Text)
$result = mysql_query("SELECT * FROM images WHERE 'Broad1'='$thumb_name'");
php Syntax (Toggle Plain Text)
$result = mysql_query("SELECT * FROM images WHERE Broad1='$thumb_name'");
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
•
•
•
•
And
Should bephp Syntax (Toggle Plain Text)
$result = mysql_query("SELECT * FROM images WHERE 'Broad1'='$thumb_name'");
No quotes around Broad1.php Syntax (Toggle Plain Text)
$result = mysql_query("SELECT * FROM images WHERE Broad1='$thumb_name'");
Ah! correct.. I couldn't spot that one!
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
i have correct the few lines of code which were wrong but it is now saying that the table i have created does not exist. the code i have used to create the table is
[code=php]include "db.php";
$con = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("QUERY ERROR: ".mysql_error());
$db = mysql_select_db("$database_name", $connection)
or die("QUERY ERROR: ".mysql_error());
// Create table in $database_name database
mysql_select_db("$database_name", $connection);
$sql = "CREATE TABLE images (imageID int NOT NULL AUTO_INCREMENT, Broad1 varchar(50), Broad2 varchar(50), Broad3 varhar(50))";
mysql_query("INSERT INTO images (Broad1) VALUES ('$thumb_name')");[code]
were have i gone wrong?
[code=php]include "db.php";
$con = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("QUERY ERROR: ".mysql_error());
$db = mysql_select_db("$database_name", $connection)
or die("QUERY ERROR: ".mysql_error());
// Create table in $database_name database
mysql_select_db("$database_name", $connection);
$sql = "CREATE TABLE images (imageID int NOT NULL AUTO_INCREMENT, Broad1 varchar(50), Broad2 varchar(50), Broad3 varhar(50))";
mysql_query("INSERT INTO images (Broad1) VALUES ('$thumb_name')");[code]
were have i gone wrong?
Last edited by peter_budo : Mar 18th, 2008 at 6:13 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
You aren't executing the create table query.
After this, you need to have mysql_query($sql);
•
•
•
•
$sql = "CREATE TABLE images (imageID int NOT NULL AUTO_INCREMENT, Broad1 varchar(50), Broad2 varchar(50), Broad3 varhar(50))";
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- C-Strings : Bug in Code (C++)
- Code Check, Please (ASP)
- need help in VB Code (MS Access and FileMaker Pro)
- need help in VB Code (Visual Basic 4 / 5 / 6)
- What is wrong with my code? (C++)
- Again please someone check my code (C++)
- Please some one urgent help me in this code (C++)
- Console Window Code (Java)
- need help with code (C++)
Other Threads in the MySQL Forum
- Previous Thread: mysql loading txt file to mysql db?????????
- Next Thread: retrieve data frm 2 tables



Linear Mode