
mjgdunne
Members-
Posts
87 -
Joined
-
Last visited
Never
Everything posted by mjgdunne
-
Ok how would i go about saving the image to the server? Would i just save the link as text in the database?
-
Hi, i have a script which stores images in my databse, except i cannot seem to extract them, when i do try it prints the path to the image file. Here is my script: <?php session_start(); ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="reff"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // image and titl and reg sent from form $myimage=$_POST['myimage']; $mymake=$_POST['mymake']; $mymodel=$_POST['mymodel']; $myreg=$_POST['myreg']; mysql_select_db("test"); mysql_query("INSERT INTO reff (make, model, registration, imgdata) VALUES ('$_POST[mymake]', '$_POST[mymodel]', '$_POST[myreg]', '$_POST[myimage]')"); echo "Data saved"; exit(); ?> Any help would be great.
-
Thank you, iv been looking at it so long now my eyes are gone square and i missed it. Thanks.
-
I ran a after the query any it prints off: But it still doesnt update the database? This is really bugging me any help would be great. ???
-
Sorry i forgot to add the code: <?php $_SESSION['result'] = "$result"; ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $row = $_SESSION['members'][0]; $myid=$_POST['myid']; $myfirstname=$_POST['myfirstname']; $mysurname=$_POST['mysurname']; $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myemail=$_POST['myemail']; $mybrowser=$_POST['mybrowser']; mysql_select_db("test"); $query="update members SET Firstname='" . $_POST['myfirstname'] . "', Surname='" . $_POST['mysurname'] . "', username='" . $_POST['myusername'] . "', password='" . $_POST['mypassword'] . "', email='" . $_POST['myemail'] . "', level='" . $_POST['mybrowser'] . "' WHERE id='" . $_POST['myid'] . "'"; echo "Updated"; ?>
-
Hi, yes i have an id field in my database, i have printed it out in the edit results as: And i have changed the code below but it does not seem to update the fields, im probably missing something very simply. Thanks.
-
Hi i need to be able to update records in my mysql database, i have a search fuction which allows the admin user to update the fields these updates should be saved to the database. I am having trouble as i do not know how i would use the WHERE in the query. I am taking the information saved in a session as an array. The details are: "myfirstname" "mysurname" "myusername" "mypassword" "myemail" "mybrowser" I need to be able to update all fields. Here is my code: <?php session_start(); ?> <html> <head> <title>Car Rentals & Returns</title> <meta http-equiv="Content-Type" content="text/html" /> <link href="style2.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper3"> <img src="images/cars.jpg" width="996" height="100"></a> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <td align="center"> <H1>Details Updated</H1> <form action="login_success3.php" method="post"> </td> </table> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <TD ALIGN=CENTER VALIGN=TOP WIDTH=50> </TD> <TD ALIGN=LEFT VALIGN=TOP WIDTH=83%> <TR><TD> <?php $_SESSION['result'] = "$result"; ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $row = $_SESSION['members'][0]; $myfirstname=$_POST['myfirstname']; $mysurname=$_POST['mysurname']; $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myemail=$_POST['myemail']; $mybrowser=$_POST['mybrowser']; mysql_select_db("test"); $query="update members SET Firstname='" . $_POST['myfirstname'] . "', Surname='" . $_POST['mysurname'] . "', username='" . $_POST['myusername'] . "', password='" . $_POST['mypassword'] . "', email='" . $_POST['myemail'] . "', level='" . $_POST['mybrowser'] ."'"; echo "Updated"; ?> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <td align="center"><input type="submit" value="Home"/></td> </tr> </table> </table> </td> </form> </tr> </table> </BODY> </HTML> Any help would be great thanks.
-
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
I got it to work thanks, i used the following code: $_SESSION['members'] = array(); while ($row = mysql_fetch_assoc($result)) { $_SESSION['members'][] = $row; And i used $row = $_SESSION['members'][0]; in the second script to use the data. Thanks. -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Thanks for all your help so far, only one error left now, -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
I used if (isset($_POST['myq'])) { $myq = mysql_real_escape_string($_POST['myq']); $result = mysql_query("SELECT * FROM members WHERE Firstname LIKE '%$myq' OR Surname LIKE '%$myq'"); This is the edit results page, i need to get the results from results, do i still need a query? -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
I just replaced it, should i leave it in? Here is the code: <?php session_start(); ?> <html> <head> <title>Car Rentals & Returns</title> <meta http-equiv="Content-Type" content="text/html" /> <link href="style2.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper3"> <img src="images/cars.jpg" width="996" height="100"></a> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <td align="center"> <H1>Search Results:</H1> <form action="edit_emp.php" method="post"> </td> </table> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <TD ALIGN=CENTER VALIGN=TOP WIDTH=50> </TD> <TD ALIGN=LEFT VALIGN=TOP WIDTH=83%> <TR><TD> <?php $_SESSION['result'] = "$result"; ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $row = mysql_fetch_array($result); echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>First Name</th>"; echo "<td>"; echo '<input type="text" name="firstname" value="'. $row['Firstname'] .'" size="20" />'; echo "</td>"; echo "<tr><th>Surname</th>"; echo "<td>"; echo '<input type="text" name="surname" value="'. $row['Surname'] .'" size="20" />'; echo "</td>"; echo "<tr><th>Username</th>"; echo "<td>"; echo '<input type="text" name="username" value="'. $row['username'] .'" size="20" />'; echo "</td>"; echo "<tr><th>Password</th>"; echo "<td>"; echo '<input type="text" name="password" value="'. $row['password'] .'" size="20" />';; echo "</td>"; echo "<tr><th>Email</th>"; echo "<td>"; echo '<input type="text" name="email" value="'. $row['email'] .'" size="20" />'; echo "</td>"; echo "<tr><th>Level</th>"; echo "<td>"; echo '<input type="text" name="level" value="'. $row['level'] .'" size="20" />'; echo "</td>"; exit(); ?> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <input type="submit" value="Update Details"/> </form> <form method="post" action="login_success3.php"> <td align="center"><input type="submit" value="Home"/></form> </td> </tr> </table> </table> </td> </tr> </table> </BODY> </HTML> -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Thanks, i put that in, but two errors, any idea? Notice: Undefined variable: result in C:\xampp\htdocs\edit_emp.php on line 52 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\edit_emp.php on line 52 -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Thanks that fixed that, it is having a problem with the line: while ($row = mysql_fetch_assoc($result)) { Is there any other way i could just take $result so i can extract the name etc. Thanks. -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Hi, my button to go to the update page has dissapeared, and is not showing up along with the home button? -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Thanks, that got rid of the error, if i use the following displaying the results in input fields will it work: <?php session_start(); ?> <html> <head> <title>Car Rentals & Returns</title> <meta http-equiv="Content-Type" content="text/html" /> <link href="style2.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper3"> <img src="images/cars.jpg" width="996" height="100"></a> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <td align="center"> <H1>Search Results:</H1> <form action="edit_emp.php" method="post"> </td> </table> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <TD ALIGN=CENTER VALIGN=TOP WIDTH=50> </TD> <TD ALIGN=LEFT VALIGN=TOP WIDTH=83%> <TR><TD> <?php $_SESSION['result'] = "$result"; ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myq=$_POST['myq']; while ($row = mysql_fetch_assoc($result)) { echo "<p>You searched for: "" . $myq . ""</p>"; echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>First Name</th>"; echo "<td>"; echo '<input type="text" name="firstname" value="'. $row['Firstname'] .'" size="20" />'; echo "</td>"; echo "<tr><th>Surname</th>"; echo "<td>"; echo '<input type="text" name="surname" value="'. $row['Surname'] .'" size="20" />'; echo "</td>"; echo "<tr><th>Username</th>"; echo "<td>"; echo '<input type="text" name="username" value="'. $row['username'] .'" size="20" />'; echo "</td>"; echo "<tr><th>Password</th>"; echo "<td>"; echo '<input type="text" name="password" value="'. $row['password'] .'" size="20" />';; echo "</td>"; echo "<tr><th>Email</th>"; echo "<td>"; echo '<input type="text" name="email" value="'. $row['email'] .'" size="20" />'; echo "</td>"; echo "<tr><th>Level</th>"; echo "<td>"; echo '<input type="text" name="level" value="'. $row['level'] .'" size="20" />'; echo "</td>"; } } exit(); ?> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <input type="submit" value="Update Details"/> </form> <form method="post" action="login_success3.php"> <td align="center"><input type="submit" value="Home"/></form> </td> </tr> </table> </table> </td> </tr> </table> </BODY> </HTML> -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Here is my code: <html> <head> <title>Car Rentals & Returns</title> <meta http-equiv="Content-Type" content="text/html" /> <link href="style2.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper3"> <img src="images/cars.jpg" width="996" height="100"></a> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <td align="center"> <H1>Search Results:</H1> <form action="edit_emp.php" method="post"> </td> </table> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <TD ALIGN=CENTER VALIGN=TOP WIDTH=50> </TD> <TD ALIGN=LEFT VALIGN=TOP WIDTH=83%> <TR><TD> <?php session_start(); $_SESSION['$result'] = "variable contents"; ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myq=$_POST['myq']; if (isset($_POST['myq'])) { $myq = mysql_real_escape_string($_POST['myq']); $result = mysql_query("SELECT * FROM members WHERE Firstname LIKE '%$myq' OR Surname LIKE '%$myq'"); while ($row = mysql_fetch_assoc($result)) { echo "<p>You searched for: "" . $myq . ""</p>"; echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>First Name</th>"; echo "<td>"; echo $row['Firstname']; echo "</td>"; echo "<tr><th>Surname</th>"; echo "<td>"; echo $row['Surname']; echo "</td>"; echo "<tr><th>Username</th>"; echo "<td>"; echo $row['username']; echo "</td>"; echo "<tr><th>Password</th>"; echo "<td>"; echo $row['password']; echo "</td>"; echo "<tr><th>Email</th>"; echo "<td>"; echo $row['email']; echo "</td>"; echo "<tr><th>Level</th>"; echo "<td>"; echo $row['level']; echo "</td>"; } } if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } if (mysql_num_rows($result) == 0) { echo "No records found"; exit; } exit(); ?> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <input type="submit" value="Update Details"/> </form> <form method="post" action="login_success3.php"> <td align="center"><input type="submit" value="Home"/></form> </td> </tr> </table> </table> </td> </tr> </table> </BODY> </HTML> I am still getting the same error. -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Thanks, but im getting an error: Any idea what it could be? -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
If i use exit(); at the end if the script does that not exit the session, sorry these questions are prop very basic, thanks. -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Thanks, does this mean i can access the results in the session on any php script, and would i just use session_start(); at the start of each script. -
[SOLVED] Send results from one php script to another script
mjgdunne replied to mjgdunne's topic in PHP Coding Help
Hi, i have the following code: if (isset($_POST['myq'])) { $myq = mysql_real_escape_string($_POST['myq']); $result = mysql_query("SELECT * FROM members WHERE Firstname LIKE '%$myq' OR Surname LIKE '%$myq'"); while ($row = mysql_fetch_assoc($result)) { echo "<p>You searched for: "" . $myq . ""</p>"; So would i put $result in like: $_SESSION['$results']= "results"; -
Hi i have a basic search which works in mysql database, i now need to be able to update the information in the results fields, is there any way of echoing the results into input fields so i can update the records? Here is my code: Any help would be great, thanks. <html> <head> <title>Car Rentals & Returns</title> <meta http-equiv="Content-Type" content="text/html" /> <link href="style2.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper3"> <img src="images/cars.jpg" width="996" height="100"></a> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%> <tr> <td align="center"> <H1>Search Results:</H1> <form method="post" action="login_success3.php"> </td> </table> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <TD ALIGN=CENTER VALIGN=TOP WIDTH=50> </TD> <TD ALIGN=LEFT VALIGN=TOP WIDTH=83%> <TR><TD> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="customers"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myq=$_POST['myq']; if (isset($_POST['myq'])) { $myq = mysql_real_escape_string($_POST['myq']); $result = mysql_query("SELECT * FROM customers WHERE firstname LIKE '%$myq' OR surname LIKE '%$myq'"); while ($row = mysql_fetch_assoc($result)) { echo "<p>You searched for: "" . $myq . ""</p>"; echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>Title</th>"; echo "<td>"; echo $row['title']; echo "</td>"; echo "<tr><th>First Name</th>"; echo "<td>"; echo $row['firstname']; echo "</td>"; echo "<tr><th>Surname</th>"; echo "<td>"; echo $row['surname']; echo "</td>"; echo "<tr><th>Age</th>"; echo "<td>"; echo $row['age']; echo "</td>"; echo "<tr><th>Email</th>"; echo "<td>"; echo $row['email']; echo "</td>"; echo "<tr><th>Address</th>"; echo "<td>"; echo $row['address']; echo "</td>"; echo "<tr><th>Credit Card Details</th>"; echo "<td>"; echo $row['']; echo "</td>"; echo "<tr><th>Tile</th>"; echo "<td>"; echo $row['title2']; echo "</td>"; echo "<tr><th>First Name</th>"; echo "<td>"; echo $row['firstname2']; echo "</td>"; echo "<tr><th>Surname</th>"; echo "<td>"; echo $row['surname2']; echo "</td>"; echo "<tr><th>Card Type</th>"; echo "<td>"; echo $row['cardtype']; echo "</td>"; echo "<tr><th>Date</th>"; echo "<td>"; echo $row['date']; echo "</td>"; echo "<tr><th>Date</th>"; echo "<td>"; echo $row['date2']; echo "</td>"; echo "<tr><th>Verification</th>"; echo "<td>"; echo $row['verification']; echo "</td>"; echo "<tr><th>Address</th>"; echo "<td>"; echo $row['address2']; echo "</td>"; } } if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } if (mysql_num_rows($result) == 0) { echo "No records found"; exit; } ?> <TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%> <tr> <td align="center"><input type="submit" value="Home"/></td> </tr> </table> </table> </td> </form> </tr> </table> </BODY> </HTML>
-
Hi I am having trouble displaying images stored in a mysql database, when i run the script all i am getting is the location path to the image, is there any way of displaying the images, here is my my code: <?php session_start(); ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="pix"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myq=$_POST['myq']; if (isset($_POST['myq'])) { $myq = mysql_real_escape_string($_POST['myq']); $result = mysql_query("SELECT * FROM pix WHERE title LIKE '%$myq' OR registration LIKE '%$myq'"); while ($row = mysql_fetch_array($result)) { echo "<p>You searched for: "" . $myq . ""</p>"; echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>Car Make</th>"; echo "<td>"; echo $row['title']; echo "</td>"; echo "<tr><th>Image</th>"; echo "<td>"; echo $row["imgdata"]; echo "</td>"; echo "<tr><th>Registration</th>"; echo "<td>"; echo $row['registration']; echo "</td>"; } } if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } if (mysql_num_rows($result) == 0) { echo "No records found"; exit; } exit(); ?>
-
I new to php programming, so i cant just do a echo and print out the image no? How would i go about getting it to work?
-
Hi i have stored information into mysql database, when i do a search for the using the title or reg of the car the image does not display is there anything else i need to add to get this to display. The images are displayed as longblob attributes binary. Any help would be great thanks. <?php session_start(); ini_set( 'display_errors', '1' ); error_reporting ( 2047 ); $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="test"; // Database name $tbl_name="pix"; // Table name // Connect to server and select databse. mysql_connect("$host", "root", "root")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myq=$_POST['myq']; if (isset($_POST['myq'])) { $myq = mysql_real_escape_string($_POST['myq']); $result = mysql_query("SELECT * FROM pix WHERE title LIKE '%$myq' OR registration LIKE '%$myq'"); while ($row = mysql_fetch_assoc($result)) { echo "<p>You searched for: "" . $myq . ""</p>"; echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>Car Make</th>"; echo "<td>"; echo $row['title']; echo "</td>"; echo "<tr><th>Image</th>"; echo "<td>"; echo '<img src="'.$row['imgdata'].'"/>'; echo "</td>"; echo "<tr><th>Registration</th>"; echo "<td>"; echo $row['registration']; echo "</td>"; } } if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } if (mysql_num_rows($result) == 0) { echo "No records found"; exit; } exit(); ?>