HuggieBear
Members-
Posts
1,899 -
Joined
-
Last visited
Everything posted by HuggieBear
-
This is the code that's causing problems... [code] // make sure we have a valid product if($product != "" && $product != null) echo "<td><td><img src=$Image alt=$Alt border=0 align=bottom hspace=5 vspace=5></td></td>"; [/code] For the time being, remove the condition and see if it works at all... Try this: [code] // make sure we have a valid product // if($product != "" && $product != null) // temporary comment out echo <<<HTML <td><img src="{$Image}" alt="{$Alt}" border="0" align="bottom" hspace="5" vspace=5></td> HTML; [/code] Regards Huggie
-
What do I need to do to call an image in php?
HuggieBear replied to 11Tami's topic in PHP Coding Help
If the above doesn't work, then post your code. Regards Huggie -
Thanks for the update Trillion. Regards Huggie
-
OK, try changing to this: [code] <?php $y = <<<HTML <table align="center" border="0" cellpadding="0" cellspacing="0" width="145"> <tr> <td width="16"><img src="about_files/top_lef.gif" alt="a" width="16" height="16"> </td> <td background="about_files/top_mid.gif" height="16"> <img src="about_files/top_mid.gif" alt="a"> </td> <td width="16"> <img src="about_files/top_rig.gif" alt="a" width="16" height="16"> </td> </tr> <tr> <td background="about_files/cen_lef.gif" width="16"> <img src="about_files/cen_lef.gif" alt="a"> </td> <td align="left" bgcolor="#ffffff" valign="middle"> <div align="center"> <img src="{$cat}/{$i}.jpg" width="114" height="86" border="1"> </div> </td> <td background="about_files/cen_rig.gif" width="16"> <img src="about_files/cen_rig.gif" alt="a"> </td> </tr> <tr> <td height="16" width="16"> <img src="about_files/bot_lef.gif" alt="a" width="16" height="16"> </td> <td background="about_files/bot_mid.gif" height="16"> <img src="about_files/bot_mid.gif" alt="a"> </td> <td height="16" width="16"> <img src="about_files/bot_rig.gif" alt="a" width="16" height="16"> </td> </tr> </table> HTML; echo "$y"; ?> [/code] Regards Huggie
-
Insert record into MYSQL table as part of PHPmailer script
HuggieBear replied to eskimowned's topic in PHP Coding Help
Line 15 is this: [code=php:0] mysql_query("INSERT INTO CUSTOMER (Company, First Name, Last Name, Event, price) VALUES ('$Company', '$first', '$last', '$event', '$price')"); [/code] Regards Huggie -
You've got it!... Well done... The reason you have this tiny error is that you have 1 character wrong, a (?) instead of an (&)... Where the page numbers are displayed at the bottom of the page, change this line: [code=php:0]<a href=\"?cat=$cat?page=$i\">[/code] To this: [code=php:0]<a href=\"?cat=$cat[/code][b]&[/b][color=red]page=$i\">[/color] Regards Huggie
-
Insert record into MYSQL table as part of PHPmailer script
HuggieBear replied to eskimowned's topic in PHP Coding Help
Try this... [code] <?php $sql = "INSERT INTO customer (`Company`, `First Name`, `Last Name`, `Event`, `price`) VALUES ('$Company', '$first', '$last', '$event', '$price')"; $inserted = mysql_query($sql) or die ("Can't execute sql\n\n$sql\n\n" . mysql_error()); if ($inserted == true){ echo "Insert successful\n"; } else { echo "Insert failed\n"; } ?> [/code] Regards Huggie -
Yes that's correct, When you use mysql_query() a Resource ID is returned from it, ultimately it's a 'results table'. Try checking [url=http://uk.php.net/manual/en/function.mysql-query.php]this link[/url] out? Regards Huggie
-
[quote] The code you have listed will not work because it echoes the include command into HTML where it has no meaning outside PHP. [/quote] I'm fully aware of that :) I only put that there for an example. I don't have any files to include, so it would have been pointless me including them. I personally don't think you should use include files either, you should construct the tables manually in the php. Anyway, I'm assuming that although you've posted elsewhere and been told it's not correct (which we already knew) the code itself actually works? Regards Huggie
-
No problem, but I have a feeling you'll be back before it's totally finished ;) Regards Huggie
-
When the first form is submitted, you place the id into a session variable... [code] <?php sesion_start(); $_SESSION['id'] = $_GET['id']; ?> [/code] Then you create your if statement... [code] <?php if ($_GET['type'] == "Hotel"){ header("Location: hotel.php"); } else if ($_GET['type'] == "Villa"){ header("Location: villa.php"); } else if ($_GET['type'] == "Golf"){ header("Location: golf.php"); } ?> [/code] Then your golf.php looks something a little like this: [code] <?php session_start() echo <<<HTML <input type="hidden" name="id" value="{$_SESSION['id']}"> <input type="text" name="details"> HTML; ?> [/code] Regards Huggie
-
OK, Here's the code I came up with, the only problem is you'll have to substitute it with your sql as opposed to mine... but you can see it in action [url=http://www.dizzie.co.uk/php/sbspage2.php]here[/url] [code] <?php // Connect to DB include('connect.php'); // Select total results for pagination $result = mysql_query('SELECT count(countryName) FROM tblCountry'); $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 2; $max_num_columns = 2; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $result = mysql_query("SELECT countryName FROM tblCountry ORDER BY countryName LIMIT $start, $per_page"); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); // Echo the results echo "<table border=\"2\">\n"; for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr>\n"; for ($c = 0; $c < $max_num_columns; $c++){ // 1 $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){ // $y = mysql_result($result, $x, 0); // Commented out so I could show your example $y = "include('table.php')"; } else { $y = "include('table-no.php')"; } echo "<td>$y</td>"; } echo "</tr>\n"; } // Echo page numbers echo "</table>\n"; for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?page=$i\">$i</a> "; } ?> [/code] Regards Huggie
-
Using phpmailer - File attachment problem
HuggieBear replied to Connexion's topic in PHP Coding Help
I've never used phpMailer before, but the below line doesn't look right to me. [code] $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/".$image_list[0],$image_list[0]"); [/code] You could try: [code] $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/{$image_list[0]}", "$image_list[0]"); [/code] Also, I know that AddAttachment returns false if it can't find or access the file, if AddStringAttachment does, you could try something like this: [code] <?php $attachtest = $mail->AddStringAttachment("http://aerocomm.jobtrackonline.com/jobphotos/{$image_list[0]}", "$image_list[0]"); if ($attachtest == false){ echo "Didn't like this line\n"; } ?> [/code] Anyway, like I said, these are only suggestions as I've never used the class before. Regards Huggie -
Why not have something like this: [code] <?php $sql = "SELECT product_id, color FROM product_colors ORDER BY product_id, color"; $result = mysql_query($sql); $product = null; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $product_id = $row['product_id']; if (is_null($product) || strcmp($product, $product_id) !=0){ $product = $product_id; echo "<br>$product_id<br>\n"; } echo "$row['color']<br>\n"; } ?> [/code] I've used the same column headings as in your table, so you should just be able to provide your database connect string and give it a whirl. Regards Huggie
-
Could even be simplified to: [code=php:0]$sql = "SELECT max(message_id) FROM tablename"; [/code] If you're just going to us an alias of exactly the same name, surely there's no point? Regards Huggie
-
It really does depend on how you've got your database setup as to how easy it is. As with most things, it's possible, but I don't think it's going to be easy. Have you modified the database at all, or is it the default OsCommerce one? Perhaps it would be better posted in the third-party forum. Don't forget to include the version ;) Regards Huggie
-
Hey, haven't been home this evening, but should be able to post tomorrow when I do. Regards Huggie
-
You could put them in a private folder out of your public area and use an include to call it, but don't forget php is a server side scripting, so it's not going to be visible from the front-end Regards Huggie
-
You need to do something with your result resource to extract the data from it. Lets look at your query... [code=php:0]$sql = "SELECT COUNT(*) FROM pictures WHERE picture_albumid = 1"; [/code] Now count() is what's known as a single row query, if you use count() in a statement, you're only expecting one row returned, so if you get your result resource like so... [code=php:0]$numofpics = mysql_query($sql);[/code] We expect $numofpics to be one row, which it is. BUT we can't just echo it out, as you've found out, we need to extract that data, so a search of the manual tells us we can use [code=php:0]mysql_fetch_row()[/code] for getting a single row. So lets give that a try... [code=php:0]$row = mysql_fetch_row($numofpics);[/code] What this has done is put the row into an array, with each element representing a column, seen as though we only selected one column, our array only contains one element. So to echo the first element in an array all we need is... [code=php:0]echo "$row[0]";[/code] I hope this helped. Remember this is only for a single row, if you have multiple rows you'll need something like mysql_fetch_array() and you'll need to loop through them. Regards Huggie
-
Problems handling really old dates in PHP
HuggieBear replied to theOlster's topic in PHP Coding Help
As far as I know, the mktime() function gives you seconds from the epoch, which on your system is 01/01/1970 so it won't go any earlier than this without some calculation somewhere. Have you done a search on these forums? I just did a few searches and came up with a few really useful results... [url=http://www.phpfreaks.com/forums/index.php/topic,89933.0.html]Here's one[/url] for a start Regards Huggie -
Here you've posted the resulting code, can you post your php code, so we can see what's generating this result? Regards Huggie
-
I'll post my code for you this evening when I get home. Regards Huggie
-
esahp, There's nothing wrong with [b]SELECT * FROM table WHERE 1[/b] What you've read elsewhere was correct. In fact, your original query only had one thing syntactically wrong with it, it had the additional WHERE in there. When providing a second clause, just use the AND or OR. [b]SELECT * FROM table WHERE 1 AND status = 1[/b] Regards Huggie
-
$_POST form variable with a LIKE statement?
HuggieBear replied to bigkev1983's topic in PHP Coding Help
[quote] Just one last thing - if one of the fields is blank, it returns all results no matter what. Is there any way I can tell it to ignore a field if it's blank? [/quote] You mean if one of the submitted form fields is blank, or one of the database fields? Can you also tell me what column is your primary key in your directory table? Regards Huggie -
Ryan, you're spot on! I can't look at this now as I'm really busy, but I'll check this evening when I get in from work and I'll see what I can do. Regards Huggie