joshgarrod
Members-
Posts
283 -
Joined
-
Last visited
Never
Everything posted by joshgarrod
-
[SOLVED] Dynamically generated page titles
joshgarrod replied to joshgarrod's topic in PHP Coding Help
is there any way i can get around it because as you can see by my code that the loop creates the page which obviously must come after the title tag, I have turned error reporting on and still a blank page? -
[SOLVED] Dynamically generated page titles
joshgarrod replied to joshgarrod's topic in PHP Coding Help
Hi, thanks v much for the reply, I have done what you suggested and replaced my function and title tag with what you suggested but I am still getting a blank page? is it because the function is inside the loop which is after the title tag? -
Hi, i have spent hours on google looking for an anwser as I just cant seem to get this to work. It seemed simple at first, but now I am not too sure. I am displaying information of a single row on a page using a while loop. I would like to take 4 variables $make $model $year and $county to use in the title tag. This is what I have so far and it just shows me a totally blank page, it works without it it fine, where am I going wrong? <title><?php custom_title(); ?></title> <?php if(mysql_num_rows($query)==0){ die("Sorry, but the page doesnt exist!"); }else{ while($info = mysql_fetch_array($query)){ $price = number_format($info ['price']); //formatting the price to use a thousand separator echo "<div id=\"details\">"; echo "<div id=\"make\"><h1>" . $info['make'] . " " . $info['model'] . "</h1></div>"; echo "<div id=\"left_spec\">"; echo " <span class=\"price\">£$price</span>"; echo "<h2>Specification:</h2>"; echo "<div class=\"spec_item\"><strong>Year: </strong></div><div class=\"spec_detail\">" . $info ['year'] . "</div>"; echo "<div class=\"spec_item\"><img src=\"images/".$info['berth'] . ".gif\" class=\"berth\" alt=\"". $info['berth'] ." berth\"/>" .$info['berth'] . " berth</div>"; echo "<div class=\"spec_item\"><strong>MIRO: </strong></div><div class=\"spec_detail\">".$info['weightun'] . "kg</div>"; echo "<div class=\"spec_item\"><strong>MTPLM: </strong></div><div class=\"spec_detail\">".$info['weightla'] . "kg</div>"; echo "<div class=\"spec_item\"><strong>Internal: </strong></div><div class=\"spec_detail\">".$info['lengthin'] . "ft</div>"; echo "<div class=\"spec_item\"><strong>Shipping length: </strong></div><div class=\"spec_detail\">".$info['lengthex'] . "ft</div>"; echo "<div class=\"spec_item\"><strong>Awning size: </strong></div><div class=\"spec_detail\">".$info['awning'] . "cm</div>"; echo "<div class=\"spec_item\"><strong>Additional description: </strong></div><div id=\"additional\">".$info['spec'] . "</div><br />"; echo "<h2>Contact:</h2>"; echo "<div class=\"spec_item\"><strong>Contact name: </strong></div><div class=\"spec_detail\">".$info['contactname'] . "</div>"; echo "<div class=\"spec_item\"><strong>Telephone: </strong></div><div class=\"spec_detail\">".$info['contactnum'] . "</div>"; echo "<div class=\"spec_item\"><strong>Email: </strong></div><div class=\"spec_detail\"><a href=\"mailto:".$info['contactemail'] . "\">".$info['contactemail'] . "</a></div>"; echo "<div class=\"spec_item\"><strong>County: </strong></div><div class=\"spec_detail\">".$info['county'] . "</div><br /><br />"; echo "<hr width=\"90%\" class=\"solid\">"; echo "<form method='post' action='sendmail.php'> <div class=\"form_titles\">Name: </div><input name=\"name\" type=\"text\" /><br /> <div class=\"form_titles\">Email address: </div><input name=\"email\" type=\"text\" /><br /> <input name=\"hidden\" type=\"hidden\" value=\"". $info ['contactemail'] ."\" /> Enquiry:<br /> <textarea name=\"comments\" rows=\"15\" cols=\"40\"> </textarea><br /> <input type=\"submit\" /> </form>"; echo "</div>"; echo "<div id=\"right_images\">"; echo "<img src=\"".$info['image2'] . "\" class=\"display\" alt=\"". $info['make'] . " " . $info['model'] ."\"/>"; echo "<img src=\"".$info['image3'] . "\" class=\"display\" alt=\"". $info['make'] . " " . $info['model'] ."\"/>"; echo "<img src=\"".$info['image4'] . "\" class=\"display\" alt=\"". $info['make'] . " " . $info['model'] ."\"/>"; echo "<img src=\"".$info['image5'] . "\" class=\"display\" alt=\"". $info['make'] . " " . $info['model'] ."\"/>"; echo "</div>"; echo "</div>"; function custom_title() { $make = $info ['make']; $model = $info ['model']; $year = $info ['year']; $county = $info ['county']; echo "Used $make $model $year for sale in $county"; } } } ?>
-
Hi, I need to find out what the next auto increment ID is going to be when I make a submission to my database via a form because I am uploading images too and they are being stored in new folder that is made and named the same as the id so that i can link them up when displaying the data. I have this line of code at the moment to store the value of last_insert_id() into the variable $next_id but it tells me it is undefined? <?php $query = "SELECT * FROM classifieds (last_insert_id(), '$next_id')"; echo "the next ID to be inserted is $next_id"; ?> Thanks!
-
Hi, I have a script that inserts information into my database, but I also need to be able upload 4 images at the same time relevant to the unique record and create a thumbnail of the main image to display in a list (like ebay's listings) I have no idea how to do this. Does any one know of any scripts that i can modify to achieve this goal? Thanks in advance
-
Hi, I followed a similar tutorial and have checked it through but I cannot see where I have gone wrong. It is more than likely something really silly.
-
Hi all, I am having problems with pagination for my list of items. Bascially it works to the extent of showing only 10 results but when I click the Next Page link it goes to a url which is part of my local directory for the website... Any ideas? thanks in advance: <?php error_reporting (E_ALL ^ E_NOTICE); $records_per_page = 10; //number of records to be displayed per page (!$_GET['start']) ? $start = 0 : $start = $_GET['start']; mysql_connect("serv", "usr", "pass") or die(mysql_error()); mysql_select_db("quest") or die(mysql_error()); $query = "SELECT COUNT(*) FROM table"; $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); $data = mysql_fetch_row($result); $total_records = $data[0]; if (($total_records > 0) && ($start < $total_records)) { //delete from here up to start of php is broke $cond = ""; if(isset($_POST['weight']) && is_numeric($_POST['weight'])) { $weight = intval($_POST['weight']); $cond = " WHERE weightla <= {$weight}"; } $data = mysql_query("SELECT * FROM table LIMIT $start, $records_per_page".$cond); $result = mysql_query($query) or die ('Error in query: $query ' . mysql_error()); while($info = mysql_fetch_array( $data )) { Print "<div id=\"caravan_row\">"; Print "<div id=\"logo\"><a href='view_used_caravan.php?ref=".$info['ref'] ."'><img src=\"images/".$info['make'] . ".gif\" border=\"0\" /></a></div>"; Print "<div id=\"image\"><a href='view_used_caravan.php?ref=".$info['ref'] ."'><img src=\"".$info['image1'] . "\" border=\"0\" /></a></div>"; Print "<div id=\"specifications\">"; Print "<div id=\"make\"><h1></strong>".$info['make'] . " " . $info['model'] ."</h1></div>"; Print "<div id=\"price\"><span class=\"price\">£".$info['price'] . "</span></div>"; Print "<div id=\"more\"><a href='view_used_caravan.php?ref=".$info['ref'] ."'>More info>></a></div>"; Print "<div id=\"year\"><strong>Year: </strong>".$info['year'] . " </div>"; Print "<div id=\"weightun\"><strong>MIRO: </strong>".$info['weightun'] . "kg</div>"; Print "<div id=\"berth\"><img src=\"images/".$info['berth'] . ".gif\" class=\"berth\" />" .$info['berth'] . " berth</div>"; Print "<div id=\"weightla\"><strong>MTPLM: </strong>".$info['weightla'] . "kg</div>"; Print "<div id=\"lengthex\"><strong>Shipping length: </strong>".$info['lengthex'] . "ft</div>"; Print "</div>"; Print "</div>"; } if ($start >= $records_per_page) { echo "<a href=" . $_SERVER['PHP_SELF'] . "?start=" . ($start-$records_per_page) . ">Previous Page</a> "; } if ($start+$records_per_page < $total_records && $start >= 0) { echo "<a href=" . $_SERVER['PHP_SELF'] . "?start=" . ($start+$records_per_page) . ">Next Page</a>"; } } ?>
-
[SOLVED] problem with classified advert script
joshgarrod replied to joshgarrod's topic in PHP Coding Help
sorry to waste everyones time, i have figured it. forgot two } at the end. duh -
[SOLVED] problem with classified advert script
joshgarrod replied to joshgarrod's topic in PHP Coding Help
I have been trying to fix it while I am waiting and I think I am a bit closer. I am receing this error: but line 78 is the </html> tag??? Here is the code for the page with all of the listings: <?php mysql_connect("serv", "usr", "pass") or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); $cond = ""; if(isset($_POST['weight']) && is_numeric($_POST['weight'])) { $weight = intval($_POST['weight']); $cond = " WHERE weightla <= {$weight}"; } $data = mysql_query("SELECT * FROM classifieds".$cond); while($info = mysql_fetch_array( $data )) { Print "<div id=\"caravan_row\">"; Print "<div id=\"logo\"><img src=\"images/".$info['make'] . ".gif\" /></div>"; Print "<div id=\"image\"><img src=\"".$info['image'] . "\" /></div>"; Print "<div id=\"specifications\">"; Print "<div id=\"make\"><h1></strong>".$info['make'] . " " . $info['model'] ."</h1></div>"; Print "<div id=\"price\"><span class=\"price\">£".$info['price'] . "</span></div>"; Print "<div id=\"year\"><strong>Year: </strong>".$info['year'] . " </div>"; Print "<div id=\"weightun\"><strong>Unladen weight: </strong>".$info['weightun'] . "kg</div>"; Print "<div id=\"berth\"><img src=\"images/".$info['berth'] . ".gif\" class=\"berth\" />" .$info['berth'] . " berth</div>"; Print "<div id=\"weightla\"><strong>Laden weight: </strong>".$info['weightla'] . "kg</div>"; Print "<div id=\"lengthex\"><strong>Shipping length: </strong>".$info['lengthex'] . "ft</div>"; Print "<div id=\"more\"><a href='view_used_caravan.php?ref=".$info['ref'] ."'>More info>></a></div>"; Print "</div>"; Print "</div>"; } ?> And here is the code for the page to view more info on a specific item: <?php $con = mysql_connect("serv","usr","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $page = $_GET['ref']; // This will be the ID of the page $page = mysql_real_escape_string(strip_tags($page)); $query = mysql_query("SELECT * FROM classifieds WHERE `ref` = '$page'"); if(mysql_num_rows($query)==0){ die("Sorry, but the page doesnt exist!"); }else{ while($info = mysql_fetch_array($query)){ echo "<div id=\"make\">" . $info['make'] . "</div>"; ?> -
Hi everyone, I am trying to write a classified advrt script. So far I have managed to retrieve and display all of the information I want to in the list, however, I cant get my "more info" link to work to enable a click through to the page where you see all the information about the item. I know it is something stupid but I can't see it. Can any body help? Thanks in advance.... <?php mysql_connect("213.171.200.50", "usr", "pass") or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); $cond = ""; if(isset($_POST['x']) && is_numeric($_POST['x'])) { $x = intval($_POST['x']); $cond = " WHERE weight <= {$x}"; echo "You entered " .$x. "kg"; } $data = mysql_query("SELECT * FROM table".$cond); while($info = mysql_fetch_array( $data )) { $i=0; $ref=mysql_result($info,$i,"ref"); Print "<div id=\"caravan_row\">"; Print "<div id=\"logo\"><img src=\"images/".$info['make'] . ".gif\" /></div>"; Print "<div id=\"image\"><img src=\"".$info['image'] . "\" /></div>"; Print "<div id=\"specifications\">"; Print "<div id=\"make\"><h1></strong>".$info['make'] . " " . $info['model'] ."</h1></div>"; Print "<div id=\"price\"><span class=\"price\">£".$info['price'] . "</span></div>"; Print "<div id=\"year\"><strong>Year: </strong>".$info['year'] . " </div>"; Print "<div id=\"weightun\"><strong>Unladen weight: </strong>".$info['weightun'] . "kg</div>"; Print "<div id=\"berth\"><img src=\"images/".$info['berth'] . ".gif\" class=\"berth\" />" .$info['berth'] . " berth</div>"; Print "<div id=\"weightla\"><strong>Laden weight: </strong>".$info['weightla'] . "kg</div>"; Print "<div id=\"lengthex\"><strong>Shipping length: </strong>".$info['lengthex'] . "ft</div>"; Print "<div id=\"more\"><a href='view_used_caravan&caravan=$ref'>More info>></a></div>"; Print "</div>"; Print "</div>"; } ?>
-
[SOLVED] Problems deleting a record from database
joshgarrod replied to joshgarrod's topic in PHP Coding Help
perfect thanks so much -
[SOLVED] Problems deleting a record from database
joshgarrod replied to joshgarrod's topic in PHP Coding Help
sorry but its still not working ??? -
[SOLVED] Problems deleting a record from database
joshgarrod replied to joshgarrod's topic in PHP Coding Help
ok i added the or die(mysql_error()); but it hasn't made any difference -
hiy guys, I i am having issues with my delete script. it just reloads the page, changes the id in the url but it doesnt remove it? any ideas? thanks in advance: <?php $con = mysql_connect("host","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $query = "SELECT * FROM `awnings`"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { echo("<table border='1' wIDth='100%' align='center'>\n"); echo("<tr>\n"); print("<td width='19%' align=center><em>Make: </em>$row[1]</td>\n"); print("<td width='19%'align=center><em>Model: </em>$row[2]</td>\n"); print("<td width='19%'align=center><em>Size: </em>$row[3]</td>\n"); print("<td width='19%'align=center><em>Year: </em>$row[4]</td>\n"); print("<td width='19%'align=center><em>Price: </em>$row[6]</td>\n"); print("<td width=10px><font size=1><a href='used_caravan_awnings_edit.php?ID=$row[0]'><font size=1>Delete Record</a></font>"); echo("</table>\n"); } if ($ID == NULL) { //do notning }else{ //get ID $ID=$_GET['ID']; print("ID: $ID"); $query = "DELETE FROM `awnings` WHERE ID LIKE '$ID' "; $result = mysql_query($query); if (mysql_affected_rows() == 1) { print '<p>The stock has been deleted</p>'; }else{ print "<p>Could not delete the entry because <b>" . mysql_error() . "</b>. The query was $query.</p>"; } } ?>
-
[SOLVED] problems inserting data into database
joshgarrod replied to joshgarrod's topic in PHP Coding Help
thanks very much works fine now thanks again -
[SOLVED] problems inserting data into database
joshgarrod replied to joshgarrod's topic in PHP Coding Help
i am also getting this: ERROR: Column count doesn't match value count at row 1 INSERT INTO awnings (Make, Model, Size, Year, Price, Description) VALUES ('','','',', , ') -
[SOLVED] problems inserting data into database
joshgarrod replied to joshgarrod's topic in PHP Coding Help
<?php $usr = "user"; $pwd = "pword"; $db = "database"; $host = "host"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } if ($_POST['submit']) { $SQL = " INSERT INTO awnings "; $SQL .= " (Make, Model, Size, Year, Price, Description) VALUES "; $SQL .= " ('$Make','$Model','$Size','$Year, $Price, $Description') "; $result = mysql_db_query($db,$SQL,$cid); $ID=mysql_insert_id(); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo ("<P><B>New awning has been added, thank you</B></P>\n"); } ?> <FORM NAME="fa" ACTION="add_used_awnings.php" METHOD="POST"> Make: <INPUT NAME="Make" TYPE="text" id="Make" SIZE=40><br /><br /> Model: <INPUT TYPE="Model" NAME="Model" VALUE="" SIZE=15><br /><br /> Size: <input name="Size" type="text" id="Size" value="" size="15" /><br /><br /> Year: <input name="Year" type="text" id="Year" value="" size="15" /><br /><br /> Price: <input name="Price" type="text" id="Price" value="£" size="15" /><br /><br /> Description: <textarea name="Description" cols="50" rows="10" id="Description" type="text" value="" /></textarea><br /><br /> <input name="submit" type="submit" value="Add stock" /> </FORM> <?php mysql_close($cid); ?> -
[SOLVED] problems inserting data into database
joshgarrod replied to joshgarrod's topic in PHP Coding Help
no i have left out the database connection code for this post so its not that i dont think -
[SOLVED] problems inserting data into database
joshgarrod replied to joshgarrod's topic in PHP Coding Help
it submits and says that the awning has been added but it doesn't actually make it to the database, do i need to include the ID? -
Hi guys, noob here as you will guess, I am having trouble with this script, it merely refreshes the page when you click the submit button, what am I doing wrong? <?php (POST METHOD) if ($REQUEST_METHOD=="POST") { $SQL = " INSERT INTO awnings "; $SQL = $SQL . " (Make, Model, Size, Year, Price, Description) VALUES "; $SQL = $SQL . " ('$Make','$Model','$Size','$Year, $Price, $Description') "; $result = mysql_db_query($db,"$SQL",$cid); $ID=mysql_insert_id(); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo ("<P><B>New awning has been added, thank you</B></P>\n"); } ?> <FORM NAME="fa" ACTION="add_used_awnings.php" METHOD="POST"> Make: <INPUT NAME="Make" TYPE="text" id="Make" SIZE=40><br /><br /> Model: <INPUT TYPE="Model" NAME="Model" VALUE="" SIZE=15><br /><br /> Size: <input name="Size" type="text" id="Size" value="" size="15" /><br /><br /> Year: <input name="Year" type="text" id="Year" value="" size="15" /><br /><br /> Price: <input name="Price" type="text" id="Price" value="£" size="15" /><br /><br /> Description: <textarea name="Description" cols="50" rows="10" id="Description" type="text" value="" /></textarea><br /><br /> <input name="submit" type="submit" value="Add stock" /> </FORM>
-
Auto XML sitemap generated by PHP reading website
joshgarrod replied to joshgarrod's topic in PHP Coding Help
I have done some research and all I can find are these crappy off the shelf software packages that do half the job... any ideas?