Canman2005
-
Posts
669 -
Joined
-
Last visited
Never
Posts posted by Canman2005
-
-
Hi all
I have a simple shopping cart which when you add an item to the cart, the following code is run;
switch ($action) { case 'add': if ($cart) { $cart .= ','.$_REQUEST['id']; header("Location: cart.html"); exit; } else { $cart = $_REQUEST['id']; header("Location: cart.html"); exit; } break;
this has worked fine on my local web server, but when I upload it to the website server I run into some issues.
Firstly the above code doesn't work and no items are added, but if I remove
header("Location: cart.html"); exit;
then the code does run ok, the problem is that if it doesn't do a "header("Location")" then I still have
?action=add&id=2
showing in the URL, therefore if the page is reloaded, the quantity of that item increases by 1.
Does anyone know why a
header("Location: cart.html");
is stopping?
One thing I did notice was that "register_globals" is turned off, I found if I add
register_globals = on
to a php.ini file, the site runs fine.
Can anyone help?
Thanks
-
any ideas anyone?
-
Hi all
I have the following function code to highlight text on a page
function highlight_words($str, $keywords = '') { $keywords = preg_replace('/\s\s+/', ' ', strip_tags(trim($keywords))); $style = 'highlight'; $var = ''; foreach(explode(' ', $keywords) as $keyword) { $replacement = '<span class="highlight">'.$keyword.'</span>'; $var .= $replacement." "; $str = eregi_replace($keyword, $replacement, $str); } print eregi_replace(rtrim($var), '<span class="highlight">'.$keywords.'</span>', $str); }
and I use the function like
<?php highlight_words(''.$row_contents['title'].'',''.$_GET['q'].''); ?>
this works fine, but I have found an issue.
Basically I have a entry in my database titled
get a quote
If I use my highlight function and set the value of $_GET['q'] as
?q=get+a
then
Instead of simply doing
<span class="highlight">get</span> <span class="highlight">a</span> quote
like it should, it returns instead
<sp><span class="highlight">a</span>n cl<span class="highlight">a</span>ss="highlight">get</sp><span class="highlight">a</span>n> <span class="highlight">a</span> quote
Any ideas why this is happening?
Looks like it's treating the html tags are text to highlight
Any help would be magic
Thanks
Mark
-
Hi all
I wonder if you can help.
I have this code
$startdate = "10 october 2009"; function printMonths($var) { $start = strtotime($var); $now = strtotime("Now"); while ($start < $now) { echo date("F Y", $start); echo "<br>"; $start = strtotime("+1 month", $start); } } printMonths($startdate);
which works fine and gives me
October 2009
November 2009
but is it possible, to list the next 12 months and inbetween each month also list each day of that month?
thanks everyone
dave
-
Hi
Yep, it is a numeric number.
I have altered my query to
SELECT m.id, m.parentId, m.name, c.url, IF(m.id=1, 1, 2) as initOrder FROM menu m JOIN content c ON m.contentId = c.id WHERE ((m.parentId = 0) || (m.parentId = 1)) m.initOrder ASC, m.order ASC
but that seems to return a error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
any ideas?
-
Hi all
I want to do the following on my query
ORDER BY m.order ASC
which works fine, but s it possible to do the above ORDER BY but always have row `id` number 1 at the first?
Thanks
-
Hi all
Just a general question really, but I have quite a few forms on a php website I have built, many of the forms used do a POST to send the data, and then my php scripts deal with the posted data from the forms.
Often if I have submitted a form and the PHP has done its magic, when I go back through the page history by clicking the back or forward buttons, I tend to get the messge from Firefox
"To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier."
and if "OK" is clicked, the form is submitted again, the data posted and the php scripts therefore run again.
This can be annoying as sometimes the form is posting data and the php is updating data or even deleting records.
What is the best way to overcome this and only allow the form to be posted when the submit button is clicked.
I have looked around online in the past, but never managed to find any good solutions.
Thanks
Dave
-
figured it, thanks for inital help
-
If I do
SELECT * FROM `products` WHERE `name` LIKE '%adobe%' OR LIKE '%products%'
I get a
You have an error in your SQL syntax;
any ideas?
-
Nice, thanks dude
-
Hi all
I am building a simple search to look in multiple fields in my database based on a phrase.
Is it possible to write a query that would take a phrase such as
"Adobe Software"
and check both
"Adobe Software"
"Adobe"
"Software"
So it would basically split the phrase submitted and lookup each word in that phrase using a
LIKE %%
Any help would be great
Thanks
Ed
-
thanks
-
Hi all
I have the following
<?php $sql = "SHOW TABLES"; $result = mysql_query($sql); while ($row = mysql_fetch_row($result)) { echo "Table: {$row[0]}\n<br>"; } ?>
Which outputs
Table: admins Table: users Table: people
This is great, but I wonder if it's possible to do these 2 things;
1: Rather than displaying the table name such as "admins", it would display the "table comments", so it would look like
Table: Table of administrators Table: Table of site users Table: Table of people
2: Is it possible to tell it to exclude specified tables, such as not displaying the "admins" table? So if I excluded the "admins" table it would finally look like
Table: Table of site users Table: Table of people
Any help would be great, been searching Google for ages now with no luck
Thanks in advance
Dave
-
thanks dude, it was 3600
-
Hi all
I have 2 vars set
$start = '2009-10-02 12:34:44'; $end = '2009-10-03 13:34:44';
how can I work out the total hours betwen those 2 dates, so with the above it would output 25
thanks for any help
-
Figured it out
<?php function dates($start,$end) { $ret = array(); $sts = strtotime($start); $ets = strtotime($end); if ($ets < $sts) return (false); for($i=$sts;$i<=$ets;$i+=86400) $ret[] = $i; return($ret); } $dates = dates('2009-01-20','2009-02-05'); if (is_array($dates)) foreach ($dates as $dt) echo date('Y-m-d',$dt) . '<br>'; ?>
-
Any ideas anyone?
Thanks
-
Hi all
I have the following table
`date` date `day` int(2) `month` int(2) `year` int(4)
If I pass a date range in PHP, such as
$datefrom = '2009-02-20'; $dateto = '2009-02-25';
How can I get it to INSERT a record for every date between that date range?
So with that example date range, it would do
INSERT INTO `dates` (`date`, `day`, `month`, `year`) VALUES ('2009-02-20', '20', '02', '2009'), ('2009-02-21', '21', '02', '2009'), ('2009-02-22', '22', '02', '2009'), ('2009-02-23', '23', '02', '2009'), ('2009-02-24', '24', '02', '2009'), ('2009-02-25', '25', '02', '2009')
but not do an INSERT if any of those dates already exists in the database.
Any help would be great
Thanks very much
Ed
-
Hi all
I'm generating a checkbox using
var cellRightSel = row.insertCell(4); var sel = document.createElement("input"); sel.className = 'formfield'; sel.name = 'daycare' + iteration; sel.type = "checkbox"; sel.checked = false; cellRightSel.appendChild(sel);
if I use
sel.onclick = function(){ alert('clicked')}
then I can get it to display an alert message when clicked.
Is it possible to change that so when clicked, it would dynamically display two blank text fields rather than the alert message?
thanks
-
I've managed to add in the following to that code
<script> function ajaxLoader(url,id) { if (document.getElementById) { var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); } if (x) { x.onreadystatechange = function() { el = document.getElementById(id); el.innerHTML = ""; if (x.readyState == 4 && x.status == 200) { el = document.getElementById(id); el.innerHTML = x.responseText; } } x.open("GET", url, true); x.send(null); } } </script> <script> $(document).ready(function(){ $("ul.sortable").tree({ dropOn: ".item_name", placeholder: 'placeholder', tabSize: 20, maxDepth: 2, maxDepthError: 'ui-tree-deptherror', maxDepthErrorText: 'Only three levels are alowed!', maxItems: [7], maxItemsError: 'ui-tree-limiterror', maxItemsErrorText: 'You have reached the maximum number of items for this level!' }); $("#serializebtn").click(function(){ var sorte = $("ul.sortable").tree("serialize"); ajaxLoader('update.php?action='+sorte+'','content'); }); }); </script> <span id="content"></span>
which posts to a database when the
<a href="#" id="serializebtn">serialize</a>
link is clicked.
but it is only inserting
list[]=1
into the database.
how can I get it to post the correct data?
thanks
-
Hi all
I have found this script which is perfect
http://sandbox.tinctuur.be/tree/
how easy would it be to store the position and menu options in a database and update the position of each using PHP?
Thanks
-
Hi all
Are sessions the best way to secure blocks of HTML, so for example
if($_SESSION'sessionname']) { print "show this"; }
or is there a better way to secure blocks of code?
thanks
-
Yep, I mean it runs on my local server fine, but when put online, it doesn't seem to work
-
thanks so far
my source code is
<!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=iso-8859-1" /> <title>webinn:</title> <meta name="description" content="x" /> <meta name="keywords" content="x" /> <meta name="Distribution" content="Global" /> <meta name="Robots" content="INDEX,FOLLOW" /> <meta name="Revisit-after" content="7 Days" /> <link href="css/style.css" rel="stylesheet" type="text/css" /> </head> <script language="JavaScript"> numdivs=3 IE5=NN4=NN6=false if(document.all)IE5=true else if(document.layers)NN4=true else if(document.getElementById)NN6=true function init() { showDiv(0) } function showDiv( which ) { for(i=0;i<numdivs;i++) { if(NN4) eval("document.div"+i+".visibility='hidden'") if(IE5) eval("document.all.div"+i+".style.visibility='hidden'") if(NN6) eval("document.getElementById('div"+i+"').style.visibility='hidden'") } if(NN4) eval("document.div"+which+".visibility='visible'") if(IE5) eval("document.all.div"+which+".style.visibility='visible'") if(NN6) eval("document.getElementById('div"+which+"').style.visibility='visible'") } </script> <script src="js/ajax.js" type="text/javascript"></script> <script src="js/ajax-alt.js" type="text/javascript"></script> <script type="text/javascript" src="js/ajax-Tooltip.js"></script> <script type="text/javascript" src="js/ajax-dynamic-content.js"></script> <script> function QuickPreview() { window.open("websitepreview.php","mywindow","menubar=1,resizable=1,width=650,height=450"); } </script> <link rel="stylesheet" type="text/css" href="css/contentslider.css"/> <link rel="stylesheet" href="css/ajax-Tooltip.css" media="screen" type="text/css"> <style> #div0 { position:absolute; width:870px; padding-top:10px; visibility: hidden; } #div1 { position:absolute; width:870px; padding-top:10px; visibility: hidden; } #div2 { position:absolute; width:870px; padding-top:10px; visibility: hidden; } #stripNav1 a { font-size: 18px; text-decoration:none; left:20px; background-color:#6e8906; position:absolute; color: #000000; height:35px; padding-left:36px; padding-right:36px; padding-top:10px; } #stripNav1 a:hover { background:#455409; color:#FFF; height:50px; } #stripNav2 a { font-size: 18px; text-decoration:none; left:150px; background-color:#6e8906; position:absolute; color: #000000; height:35px; padding-left:36px; padding-right:36px; padding-top:10px; } #stripNav2 a:hover { background:#455409; color:#FFF; height:50px; } #stripNav3 a { font-size: 18px; text-decoration:none; left:290px; background-color:#6e8906; position:absolute; color: #000000; height:35px; padding-left:36px; padding-right:36px; padding-top:10px; } #stripNav3 a:hover { background:#455409; color:#FFF; height:50px; } #stripNav4 { font-size: 18px; text-align:right; left:477px; background-color:#a4c134; width:354px; position:absolute; color: #000000; height:35px; padding-left:36px; padding-right:16px; padding-top:10px; } </style> <body onLoad="init()"> <table border="0" cellpadding="4" cellspacing="4"> <tr> <td height="70" align="left" valign="top" class="head"><img src="images/brand.gif" width="171" height="50" /></td> <td width="560" height="70" align="left" valign="top" class="head" style="padding-top:16px; padding-left:40px"><span style="font-size:22px; cursor:pointer" onclick='return QuickPreview()'>http://dasdas.webinn.com</span></td> <td height="70" align="center" valign="top" class="lrgformtext"><a href="logout.php"><img src="images/styleicons/32x32/security_lock.png" width="32" height="32" border="0" /></a><br /><a href="logout.php" style="text-decoration:none"><font color="#000000">logout</font></a></td> </tr> </table> <div id="stripNav4"><img src="images/previewbutton.gif" width="105" height="28" onclick='return QuickPreview()' style="cursor:pointer" /></div> <div id="stripNav3"><a href="javascript:showDiv(2)">Configuration</a></div> <div id="stripNav2"><a href="javascript:showDiv(1)">Content</a></div> <div id="stripNav1"><a href="javascript:showDiv(0)">Design</a></div> <div class="slider-wrap" style="margin-left:10px; padding-top:40px"> <div id="div0"> <p><span class="head"><strong>Design.</strong></span></p> <span id="designrange"><table width="860" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center" bgcolor="#CCCCCC"><table border="0" cellpadding="0" cellspacing="0"> <tr> <td height="173" align="left"><a href="#" onClick="ajaxLoader('websitelayouts.php?design=1','designrange');" ><img src="images/templates/design1fade.jpg" width="286" height="240" border="0" /></a></td> <td width="8" rowspan="2"></td> <td height="173" align="left"><a href="#" onClick="ajaxLoader('websitelayouts.php?design=2','designrange');" ><img src="images/templates/design2.jpg" width="286" height="240" border="0" /></a></td> <td width="8" rowspan="2"></td> <td height="173" valign="bottom"><a href="#" onClick="ajaxLoader('websitelayouts.php?design=3','designrange');" ><img src="images/templates/design3.jpg" width="286" height="240" border="0" /></a></td> </tr> </table></td> </tr> </table> <div style="background-color:#6e8906; height:32px; padding-left:12px; width:851px; margin-top:50px; margin-bottom:10px; padding-top:10px; font-size: 18px">copyright 2009<span style="float:right; padding-right:12px"><a href="mailto:help@webinn.com" style="text-decoration:none"><font color="#000000">contact us</font></a></span></div></span> </div> <div id="div1"> <p><span class="head"><strong>Content.</strong></span></p> <script src="js/ajax.js" type="text/javascript"></script> <script type="text/javascript"> function ProcessAction() { var action = document.getElementById('action').value; var id = document.getElementById('id').value; var pagetitle = document.getElementById('pagetitle').value; var pagecontent = document.getElementById('pagecontent').value; ajaxLoader('websitecontent.php?action='+action+'&id='+id+'&pagetitle='+pagetitle+'&pagecontent='+pagecontent+'','content'); } </script> <span id="content"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td height="34" align="left" valign="top" style="padding-right:30px"> <span style="color:#F00; font-weight:bold; padding-top:5px; padding-bottom:5px"></span> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td width="23" height="38" align="left" valign="middle" style="border-bottom:1px #999999 solid"><img src="images/icons/page.png" width="16" height="16" /></td> <td width="220" height="38" align="left" valign="middle" style="border-bottom:1px #999999 solid">Home</td> <td width="30" height="38" align="right" valign="middle" style="border-bottom:1px #999999 solid"><a onClick="ajaxLoader('websitecontent.php?edit=111','content');"><img src="images/icons/page_edit.png" width="16" height="16" border="0" style="cursor:pointer" /></a></td> <td width="26" height="38" align="right" valign="middle" style="border-bottom:1px #999999 solid"></td> </tr> <tr> <td width="23" height="38" align="left" valign="middle" style="border-bottom:1px #999999 solid"><img src="images/icons/page.png" width="16" height="16" /></td> <td width="220" height="38" align="left" valign="middle" style="border-bottom:1px #999999 solid">About Us</td> <td width="30" height="38" align="right" valign="middle" style="border-bottom:1px #999999 solid"><a onClick="ajaxLoader('websitecontent.php?edit=112','content');"><img src="images/icons/page_edit.png" width="16" height="16" border="0" style="cursor:pointer" /></a></td> <td width="26" height="38" align="right" valign="middle" style="border-bottom:1px #999999 solid"><a href="#" onClick="ajax_showTooltip('websitecontentdeletebox.php?id=112',this);return false"><img src="images/icons/cross.png" width="16" height="16" border="0" style="cursor:pointer" /></a></td> </tr> <tr> <td width="23" height="38" align="left" valign="middle" style="border-bottom:1px #999999 solid"><img src="images/icons/page.png" width="16" height="16" /></td> <td width="220" height="38" align="left" valign="middle" style="border-bottom:1px #999999 solid">Contact Us</td> <td width="30" height="38" align="right" valign="middle" style="border-bottom:1px #999999 solid"><a onClick="ajaxLoader('websitecontent.php?edit=113','content');"><img src="images/icons/page_edit.png" width="16" height="16" border="0" style="cursor:pointer" /></a></td> <td width="26" height="38" align="right" valign="middle" style="border-bottom:1px #999999 solid"><a href="#" onClick="ajax_showTooltip('websitecontentdeletebox.php?id=113',this);return false"><img src="images/icons/cross.png" width="16" height="16" border="0" style="cursor:pointer" /></a></td> </tr> <tr> <td height="48" colspan="4" align="left" valign="bottom"><input name="signup" type="button" class="smlformtext" id="button" value="New Page" onClick="ajaxLoader('websitecontent.php','content');" /></td> </tr> </table></td> <td style="padding-right:20px; border-left:1px solid #CCCCCC"> </td> <td align="left" valign="top"> <form name="theForm" id="theForm" method="post" > <table border="0" cellpadding="4" cellspacing="0"> <tr> <td align="left" valign="bottom">Page Title</td> </tr> <tr> <td align="left" valign="middle"><input name="pagetitle" type="text" class="smlformtext" id="pagetitle" size="69" value="" /></td> </tr> <tr> <td height="32" align="left" valign="bottom">Page Content</td> </tr> <tr> <td align="left" valign="top"><textarea name="pagecontent" id="pagecontent" rows="8" class="smlformtext" style="width:500px"></textarea></td> </tr> <tr> <td height="40" align="left" valign="bottom"><input type="button" class="smlformtext" value="Add Page" onclick="return ProcessAction();" /></td> </tr> </table> <input type="hidden" id="action" name="action" value="new" /> <input type="hidden" id="id" name="id" /> </form> </td> </tr> </table> </span> <div style="background-color:#6e8906; height:32px; padding-left:12px; width:851px; margin-top:50px; margin-bottom:10px; padding-top:10px; font-size: 18px">copyright 2009<span style="float:right; padding-right:12px"><a href="mailto:help@webinn.com" style="text-decoration:none"><font color="#000000">contact us</font></a></span></div></div> <div id="div2"> <p><span class="head"><strong>Configuration.</strong></span></p> <span id="configuration"><script type="text/javascript"> function ProcessFinalSave() { var sitetitle = document.getElementById('sitetitle').value; var description = document.getElementById('description').value; var keywords = document.getElementById('keywords').value; javascript:window.location='customise.php?finalsave'; } function ProcessPreview() { var sitetitle = document.getElementById('sitetitle').value; window.open("websitepreview.php?sitetitle="+sitetitle+"","mywindow","menubar=1,resizable=1,width=650,height=450"); } </script> <form method="post" enctype="multipart/form-data" target="websiteconfigurationimg" action="websiteconfigurationimg.php"> <table border="0" cellpadding="4" cellspacing="0"> <tr> <td align="left" valign="bottom">Site Title</td> <td rowspan="7" style="padding-left:20px; border-right:1px solid #CCCCCC"> </td> <td valign="bottom" style="padding-left:20px">Company Logo</td> </tr> <tr> <td height="30" align="left" valign="middle" style="padding-bottom:3px"><input name="sitetitle" type="text" class="smlformtext" id="sitetitle" value="" size="50" /></td> <td valign="bottom" style="padding-left:20px"><input name="image" type="file" class="smlformtext" id="image" size="32" onchange='this.form.submit()' /></td> </tr> <tr> <td height="32" align="left" valign="bottom">Description</td> <td rowspan="4" valign="top" style="padding-left:20px"><iframe name="websiteconfigurationimg" id="websiteconfigurationimg" width="370" height="270" frameborder="0" src="websiteconfigurationimg.php"></iframe></td> </tr> <tr> <td height="30" align="left" valign="top"><textarea name="description" cols="47" rows="4" class="smlformtext" id="description"></textarea></td> </tr> <tr> <td height="32" align="left" valign="bottom">Keywords</td> </tr> <tr> <td height="30" align="left" valign="middle"><textarea name="keywords" cols="47" rows="4" class="smlformtext" id="keywords"></textarea></td> </tr> <tr> <td height="40" align="left" valign="bottom" style="padding-top:3px"><input type="button" class="smlformtext" value="Publish Site" style="margin-right:20px" onclick='return ProcessFinalSave()' /> <input type="button" class="smlformtext" value="Preview Site" onclick='return ProcessPreview()' /></td> <td> </td> </tr> </table> <input type="hidden" name="action" id="action" value="upload" /> </form> <div style="background-color:#6e8906; height:32px; padding-left:12px; width:851px; margin-top:50px; margin-bottom:10px; padding-top:10px; font-size: 18px">copyright 2009<span style="float:right; padding-right:12px"><a href="mailto:help@webinn.com" style="text-decoration:none"><font color="#000000">contact us</font></a></span></div></span> </div> </div> </body> </html>
Help with Code
in PHP Coding Help
Posted
Hi
Nope, that didn't seem to fix the issue, still does what it did before.
Any other advice I can try?
Thanks