-
Posts
39 -
Joined
-
Last visited
Posts posted by newhip
-
-
this is where you need the SELECT query
blurb.php
<?php if (isset($_GET['id'])) { $id = intval($_GET['id']; $sql = "SELECT title, path, desct FROM media WHERE id = $id"; $result = mysql_query($sql); // process results }
Ok... but what does that have to do with the blurb.php ?
-
I'm kinda really confused now what is the blurb.php file now? is it because i shouldnt be displaying on the page that process's the upload? I still dont understand how to reference the page in the url
-
Barand is right:
<?php $conn = mysql_connect("localhost", "root", ""); $select = mysql_select_db("project", $conn); $title = mysql_real_escape_string($_POST['title'], $conn); $pic = $_FILES['pic']['tmp_name']; $pic2 = $_FILES['pic']['name']; $desc = mysql_real_escape_string($_POST['desc'], $conn); $path = mysql_real_escape_string("upload/".$pic2, $conn); $themove = move_uploaded_file($pic,$path); $sqlqry = mysql_query("INSERT INTO media(title,pic,desct) VALUES ('$title','$path','$desc')", $conn); $id = mysql_insert_id($conn); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Uploaded Page</title> </head> <body> <h1> <a href="blurb.php?id=<?php echo $id; ?>"> <?php echo htmlentities($title, ENT_QUOTES, "utf-8"); ?> </a> </h1> <br /> <br /> <img src="<?php echo htmlentities($path, ENT_QUOTES, "utf-8"); ?>" /><br /> <p> <br /> <?php echo htmlentities($desc, ENT_QUOTES, "utf-8"); ?> </p> </body> </html>
One less query...
Oh ok I think i get it. I didnt know you could do that. But like now how do i go access that page in the url with that info displayed? Like in a www.example.com/upload.php? manner?
-
Barand are you saying i should not input it in the table because im echoing it on the same page? I get that i can just echo it out on here because i grabbed the data from the form. Is that what you mean?
-
what does the blurp.php page do? or is it just an example of something i could be linking to?
-
To echo it later on in the page. Is that bad practice?
-
Ok im a super newb and i dont know how to to reference the data in my mysql table. I wrote a code that uploads a file to a server then to a database where its echoed out afterwards. The code also echoes out the id in the table's field so i know the id but i dont know how to afterwards reference it in the url. It's prob really basic but i can't figure it out. Can someone help me out or hint. Would be very appreciated. Here's the code
<?php $conn=mysql_connect("localhost","root",""); $select=mysql_select_db("project",$conn); $title=$_POST['title']; $pic=$_FILES['pic']['tmp_name']; $pic2=$_FILES['pic']['name']; $desc=$_POST['desc']; $path="upload/".$pic2; $themove=move_uploaded_file($pic,$path); $sqlqry=mysql_query("INSERT INTO media(title,pic,desct) VALUES ('$title','$path','$desc')"); echo $hmmm=mysql_insert_id($conn); $searr="SELECT * FROM media WHERE id='$hmmm'"; $seartt=mysql_query($searr); $burp=mysql_fetch_array($seartt); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Uploaded Page</title> </head> <body> <a href="#"><h1><?php echo $burp['title']; ?></h1></a><br /><br /> <img src="<?php echo $burp['pic']; ?>" /><br /><p><br /><?php echo $burp['desct']; ?></p> </body> </html>
-
Ok I'm still having some trouble. Now its echoing out the last thing input in my database and i know what the id is but how do i now reference that in my url? It might be basic stuff but i dont get it. Can anyone help?
-
wow nvm I get it thx
-
Sry i dont really understand what you mean
-
I have a basic understanding of php but there's a lot things I don't get.
I made an upload form that is processed by an upload.php file. Here's the code.
<?php
$conn=mysql_connect("localhost","root","");
$select=mysql_select_db("project",$conn);
$title=$_POST['title'];
$pic=$_FILES['pic']['tmp_name'];
$pic2=$_FILES['pic']['name'];
$desc=$_POST['desc'];
$path="upload/".$pic2;
$themove=move_uploaded_file($pic,$path);
$sqlqry=mysql_query("INSERT INTO media(title,pic,desct) VALUES ('$title','$path','$desc')");
$searr="SELECT * FROM media ";
$seartt=mysql_query($searr);
$burp=mysql_fetch_array($seartt);
$ab=mysql_query($_REQUEST['desct']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Uploaded Page</title>
</head>
<body>
<a href="#"><h1><?php echo $burp['title']; ?></h1></a><br /><br />
<img src="<?php
echo $burp['pic'];
?>" /><br /><p><br /><?php
echo $burp['desct'];
?></p>
</body>
</html>
I'm trying to request the different pages in the url for the things that are inputted in my table. Can anyone help me understand. or even remotely understand what i'm trying to do.
-
Success! thx AyKay47
-
I keep getting this error
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc) VALUES ([jskdgkfdgjgfdhfxg],[_1353564571.48585_617.png],[fhvcjhvchjvjhvgjh' at line 1 "
I know its just a dumb syntax error but i dont get it. Can someone help? struggling with this part a bit... here's the part of the code
$sqlqry=mysql_query("INSERT INTO media(title,pic,desc) VALUES ([$title],[$pic2],[$desc])");
if (!$sqlqry)
{
echo mysql_error();
}
Referencing rows
in PHP Coding Help
Posted
Ok sry Barand I'm still a little confused please bare with me ...
Are you saying that i would need to create a new page that is linked to upload.php to be able to refenrence the data in the table?