Everything posted by SpikeZ
-
Warning: Invalid argument supplied for foreach()
Pretty well what the error message said! Foreach iterates through an array, if you dont give it an array then it cant iterate and throws the error.
-
non php server
in your form simply use the action attribute: <form name="contactForm" id="contactForm" action="http://myPHPserver.com/formProcess.php">
- A little help....
-
PHP MySQL two tables in same repeating region
Darren, you need to JOIN the tables on their common fields and alias them. This probably wont run as is because I dont know your field names but it should give you an idea. select t1.product_id as t1_p_id , t1.product_name as product_name , t2.product_id as t2_p_id , t2.category_id as t2_cat_id , t3.category_id as t3_cat_id , t3.category_name as t3_cat_name from table_1 as t1 left join table_2 as t2 on ti_p_id = t2_p_id left join table_3 as t3 on t2_cat_id = t3_cat_id
-
non php server
If you have access to an different php enabled server you could direct the form action to that server instead. Then process the form and redirect back to the original site. Bit of a hack but it works.
-
A little help....
Hi, you cant start a class definition with a number so .64x64 wont parse properly. Change it to .div64x64 and amend your HTML code accordingly and it will work fine
-
uniqid()
http://uk3.php.net/uniqid read the user submitted notes.
-
uploading images to database
TBH I did the same! Wasnt until I set it up on a testbed that I noticed.
-
uploading images to database
hey Drew Answered this on SitePoint but will post here too. You have: <input name="userfile[]" type="file" /> remove the [] as it creates a multidimentional array when the form is subitted. That kills the error checking.
-
Free/cheap alternative to Dreamweaver?
phpDesigner 2008 for me, there are 2 editions - personal which is FREE and Pro which has a small fee. Tons of features if you want them as well as project management, file management and auto complete.
-
Notice: Undefined variable:
Hi again DFT, The problem stems from the location of the first $result variable. It is inside the first if() clause and so will only exist IF the form has been submitted. You then call the variable outside of the if() before the form has been submitted and so the variable hasnt been created yet - giving you the error. I would guess that moving the { on line 10 down to where the else is on line 16 would do the trick. <?php include("config.php"); if (isset($_POST["submit"])) { $txt = $_POST['txt']; $txt = mysql_real_escape_string($_POST['txt']); $result = mysql_query("UPDATE content SET txt='$txt' WHERE id='1'", $db); if ($result) { echo "<meta http-equiv=Refresh content=0;url=index.php>"; } } else { $result = mysql_query("SELECT * from content WHERE id='1'", $db); while ($row=mysql_fetch_assoc($result)){ require('fckeditor/fckeditor.php'); $oFCKeditor = new FCKeditor('txt'); $oFCKeditor->BasePath = 'fckeditor/'; $oFCKeditor->Value = $row['txt']; $oFCKeditor->Height = '300'; $oFCKeditor->Create(); } } ?>
-
Notice: Undefined variable:
Hi again DFT, The problem stems from the location of the first $result variable. It is inside the first if() clause and so will only exist IF the form has been submitted. You then call the variable outside of the if() before the form has been submitted and so the variable hasnt been created yet - giving you the error. I would guess that moving the { on line 10 down to where the else is on line 16 would do the trick. <?php include("config.php"); if (isset($_POST["submit"])) { $txt = $_POST['txt']; $txt = mysql_real_escape_string($_POST['txt']); $result = mysql_query("UPDATE content SET txt='$txt' WHERE id='1'", $db); if ($result) { echo "<meta http-equiv=Refresh content=0;url=index.php>"; } } else { $result = mysql_query("SELECT * from content WHERE id='1'", $db); while ($row=mysql_fetch_assoc($result)){ require('fckeditor/fckeditor.php'); $oFCKeditor = new FCKeditor('txt'); $oFCKeditor->BasePath = 'fckeditor/'; $oFCKeditor->Value = $row['txt']; $oFCKeditor->Height = '300'; $oFCKeditor->Create(); } } ?>
-
Replacing £ symbols with £ in a string
Have a look at http://uk.php.net/htmlspecialchars(). it converts charcters to their html entities
-
SQL Server - Setting up user permissions to view and edit website
That seems a more than logical idea
-
Header problem with MAMP
You are most welcome DFT
-
SQL Server - Setting up user permissions to view and edit website
Hi Webchap, if usera is the general public/surfers then you dont set anything up in the cpanel - they dont need it. There are a couple of ways to achieve what you want, 1/ Apache - setting up in cpanel a members/admin area using htaccess passwords 2/ Use the database to store username, password and auth levels of administrators. Either way will work but for me the database is the more logical and easier to manage (in my opinion!) Is that what you are aiming for or have I misinterpretted you?!
-
Header problem with MAMP
yes the usage is correct but the syntax is: if ($result) { header("Location: " . $_SERVER['PHP_SELF']); exit(); } PHP_SELF is all uppercase and stcik an exit() in to stop any further processing below the header.
-
search or filter results
The $listing is an array so you can check the size of it before running the foreach loop. if(count($listing) != 0) { // run it } else { //echo the 'Nothing in your area' message }
-
PHP 'Add to Cart' refresh issue
Interesting articles ElanMan but surely it would be easier to just use header("Location: xxxx.php"); and direct the user to a thank you page? This destroys the POST data and removes the refresh problem entirely. See www.php.net/header
-
javascript in php
Sorry Anna, I was working from home yesterday and didnt get back over here. Glad you got it working
-
Header problem with MAMP
Hi guys, the problem is that headers can only be called before anything - absolutely anything is sent to the browser. That anything can be whitespace before your opening <?php tag, html or javascript. Basically nothing can be sent before them. You can process anything you like before it as long as it doesntget sent to the browser. So, DFT; Yours is a simple fix in that you can move the <form> tag and line below the <?php ?> area and it will be fine, just make sure that the <?php is on line 1, column 1 of your file. HTH Spike
-
Uploading to a Directory
Hi Josh, change: $target_path = "uploads/"; to $target_path = $_POST['list'] .'/'; so that the form field called 'list' is used for the location. I would personally avoid using names like list as it is a function name as well.
-
Setting Filename as Title Tag - PHP
easiest way would be: echo "<table><tr>"; foreach(glob("images/*.{jpg,JPG,jpeg,JPEG,gif,GIF,png,PNG}", GLOB_BRACE) as $images) { $filename = $images; $title= explode(".", basename($images)); echo "<td><a href=\"".$images."\" rel=\"lightbox[holiday]\" title=\"".$title[0]."\"><img src=\"".$images."\" width=\"100px\"></a><br/>"; } echo "</tr></table>"; HTH Spike
-
javascript in php
working well anna, glad you got it sorted out btw, because you are using the javascript redirect you can remove these lines: <form action="page_2.php" method="get" name= "myform"> <input type="image" name="image" /> <input type="hidden" name="dur" value="dur" /> </form>
-
Lost dogs database and client entries
Hi Richard, yes you are correct in thinking that PHP/MySQL are right for this job. You could also use .NET etc but PHP is far easier. You could use a premade CMS such as Joomla which will have modules for adding images and details or you can sit down and learn it all from scratch! From scratch is far better IMHO as you can fix and add to it if you need to and more importantly you will understand what is happening. You will need basic sql knowledge only - insert and update, dont delete anything! Instead of deleting, set a marker field to a boolean 0 or 1 for visible or invisible. So if the record is to be displayed the field is 1, if its 'deleted' its set to 0. For the PHP side of things the main one to look at is uploading the images. You will have to decide; 1/ Are you going to generate thumbnail images when you upload them or display them 2/ Are you letting the client upload the images - if so prepare yourself for MASSIVE images straight from a digital camera! 3/ How the images are going to be displayed on the page. (thumbnails/lists etc) When you upload the image, avoid putting the image into the database. Put the image into a folder and put the image name into the database, make managing it soo much easier. Other than than, basic knowledge of forms and HTML shoudl see you through nicely Good luck Spike