Search found 622 matches

by NigelRen
Sun Aug 14, 2011 6:08 am
Forum: PHP coding => General
Topic: SimpleXML question
Replies: 6
Views: 1030

Re: SimpleXML question

There are a couple of things - the array returned from xml->xpath is actually an array of elements, the other is that your foreach uses the same variable name at both points. This example fetches JUST the title from each song and displays that. This is done by adding the /Title to the end of the XPa...
by NigelRen
Sun Aug 14, 2011 12:08 am
Forum: PHP coding => General
Topic: SimpleXML question
Replies: 6
Views: 1030

Re: SimpleXML question

Your XML file can be structured however you want - something simple like <Songs> <Song> <Artist>Tina Turner</Artist> <Title>Simply The Best</Title> <Song> <Song> <Artist>Tina Turner</Artist> <Title>Track 2</Title> <Song> </Songs> Then using SimpleXML and XPath (http://php.net/manual/en/simplexmlelem...
by NigelRen
Fri Aug 12, 2011 10:12 am
Forum: PHP coding => General
Topic: Linking from french to english
Replies: 0
Views: 511

Re: Linking from french to english

I think the easiest way of doing this is to use a session variable which is the language the user is viewing. When you click the button a page will update this. Then when your linking to a page you can simply include this into your file name ( i.e. "/$language/about.php" ).
by NigelRen
Thu Aug 11, 2011 6:53 am
Forum: mySQL & php coding
Topic: Insert text prob
Replies: 1
Views: 620

Re: Insert text prob

IMHO - you would be much better off using bind variables. This gets away from all of the problems you talk about and solves some others as well.
Have a look at some of the examples at http://php.net/manual/en/mysqli.prepare.php for some idea of what it does.
by NigelRen
Wed Aug 10, 2011 1:04 pm
Forum: PHP coding => General
Topic: Numbers
Replies: 1
Views: 587

Re: Numbers

So you want something like...

<?
$random = rand(0, 999);
printf("%1$03d", $random);
?>
by NigelRen
Wed Aug 10, 2011 12:11 pm
Forum: PHP coding => General
Topic: Numbers
Replies: 1
Views: 587

Re: Numbers

Have a look at example 5 of the sprintf manual ( http://php.net/manual/en/function.sprintf.php ). This example includes the information your after.
by NigelRen
Wed Aug 10, 2011 8:17 am
Forum: PHP coding => General
Topic: $HTTP_GET_VARS problem
Replies: 0
Views: 758

Re: $HTTP_GET_VARS problem

Have you tried $_GET & $_POST, as HTTP_GET_VARS & HTTP_POST_VARS are deprecated ( see http://www.php.net/manual/en/reserved.v ... s.post.php for example )
by NigelRen
Wed Aug 10, 2011 6:18 am
Forum: PHP coding => General
Topic: Returning Matches with wildcard
Replies: 5
Views: 1037

Re: Returning Matches with wildcard

Without really checking it - is it complaining about the / before the /td? Try adding a \ to escape the / ( i.e. <\/td> )
by NigelRen
Wed Aug 10, 2011 3:41 am
Forum: PHP General
Topic: Help with include function!
Replies: 3
Views: 634

Re: Help with include function!

Sorry if I've missed something, but surely if you used /include/menu.php - then this would always work. If you want it to work when you may have another site name at the base of your directory structure, then have a config file with $ROOT="/SomeDir"; then each time you want to include a file you inc...
by NigelRen
Wed Aug 10, 2011 3:33 am
Forum: PHP coding => General
Topic: Let people register a host
Replies: 1
Views: 684

Re: Let people register a host

When you create the copy of the site, simply have a base file for that user in the directory you create.

Something like UserID.php

Code: Select all

<?php
$UserID=10;
?>
Then just include this in your code and $UserID will always be the database reference value.
by NigelRen
Tue Aug 09, 2011 5:45 am
Forum: PHP coding => General
Topic: Populating Listbox with MySQL Database Items
Replies: 0
Views: 427

Re: Populating Listbox with MySQL Database Items

There seem to be quite a few results from searching on Google for 'php sql to listbox'. That should give you enough to work on.
by NigelRen
Tue Aug 09, 2011 5:40 am
Forum: PHP coding => General
Topic: IP Address
Replies: 2
Views: 659

Re: IP Address

There are a few possibilities- the main solution I've seen seems to be something along the lines of... if ( isset($_SERVER["REMOTE_ADDR"]) ) { $ip=$_SERVER["REMOTE_ADDR"] . ' '; } else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) { $ip=$_SERVER["HTTP_X_FORWARDED_FOR"] . ' '; } else if ( isset($_SE...
by NigelRen
Tue Aug 09, 2011 5:38 am
Forum: PHP coding => General
Topic: Fatal error: Call to undefined function
Replies: 2
Views: 485

Re: Fatal error: Call to undefined function

Are you sure that the class ( I'm assuming it's a class ) where it's being called from, includes the source with that function in.
If thats OK - can you see any other difference in the way your calling it, a sample of code that works may help.
by NigelRen
Tue Aug 09, 2011 4:16 am
Forum: PHP coding => Images
Topic: How to not include jpgs ending _w.jpg in array
Replies: 0
Views: 1653

Re: How to not include jpgs ending _w.jpg in array

You can easily check if a string ends with a particular value - use substr (http://php.net/manual/en/function.substr.php ) passing a negative value for the start position. So in your case if you say... if ( substr($image,-6) != "_w.jpg" ) { echo "slideshow.add('$image');\n"; } ( Although I haven't t...
by NigelRen
Sun Aug 07, 2011 7:22 am
Forum: PHP coding => General
Topic: Unpack 2-byte integer
Replies: 0
Views: 611

Re: Unpack 2-byte integer

Have a look at hexdec ( http://php.net/manual/en/function.hexdec.php ) which will do the basic conversion. So split the value into the components you want. The IP address will be 4 chunks of 2 characters ( so something like 192.168.0.1 ) and your port number is a 16 bit value ( 4 characters giving a...
by NigelRen
Sun Aug 07, 2011 12:09 am
Forum: PHP coding => General
Topic: email activation code - need brainstorming
Replies: 0
Views: 474

Re: email activation code - need brainstorming

Firstly - there isn't always a right and wrong way of doing things. There might be reasons why a particular style can lead to later problems, or security issues. But sometimes it's looking at the possible advantages you can get from your data. From what you say I would approach it like this ( assumi...
by NigelRen
Sat Aug 06, 2011 11:51 pm
Forum: PHP coding => General
Topic: DOMxml saving
Replies: 0
Views: 442

Re: DOMxml saving

When you load an XML document using DOMDocument, you create a copy of the document in memory. So the manipulation you are doing is only changing the copy in memory. If you want the file to be updated, do the manipulations of the DOMDocument and then use the save method (http://www.php.net/manual/en/...
by NigelRen
Fri Aug 05, 2011 10:18 am
Forum: PHP coding => Images
Topic: Viewing Image from directory HELP
Replies: 0
Views: 1025

Re: Viewing Image from directory HELP

There are a couple of things you need to do ( I think ) First is to remove the / from the end of the directory name, I think this will allow it to pick up the directory properly. The second thing is to trap if the scandir has failed. Sacndir will return false if it hasn't worked for any reason so so...
by NigelRen
Fri Aug 05, 2011 10:09 am
Forum: PHP coding => Images
Topic: Images - Remove
Replies: 0
Views: 1070

Re: Images - Remove

The problem is that the loading gif will only be displayed once the form is displayed. As your including the login code on the form - by the time the form is sent to the user, the login is already complete. The time it takes to login should be tiny ( hopefully less than the 3 second sleep ), add in ...
by NigelRen
Fri Aug 05, 2011 10:02 am
Forum: PHP coding => General
Topic: Not working!! Pls Help!!
Replies: 1
Views: 457

Re: Not working!! Pls Help!!

It's saying that you don't have permission to write to the file (the fopen at line 9). The user running the php script needs to have write permissions to count_file.txt
by NigelRen
Fri Aug 05, 2011 9:55 am
Forum: PHP coding => Images
Topic: store an image url in mysql, and display the image with mysq
Replies: 0
Views: 2741

Re: store an image url in mysql, and display the image with

Hiya
Not sure if this is the problem - but the URL your using isn't complete.

I think it should be something like

Code: Select all

$url = "http://www.blah.com/myfolder/images01.jpg";