Please help me edit this script code well - displays error

Started on the old forum in June 2012 · view the original in the archive · old links redirect here

2 replies · 461 views · started 14 years ago · 1 min read

3 participants
VCollinzo Junior · 24 posts #1
  1. $left = "{" ;
  2. $right = "}" ;
  3. foreach ( $global_whati as $sillyvar ) {
  4. $global_what [ ] = $left . $sillyvar . $right ;
  5. }
  6. $data = str_replace ( $global_what , $global_with , $data ) ;
  7. foreach ( $whati as $sillyvar ) {

It displays this error on the site

Warning : Invalid argument supplied for foreach() in /home/u601023255/public_html/config.php on line 354 . . .

and it doesn't connect to the dbase... Pls help me out wapmasters...

Ghost Senior · 366 posts #2

it is most probably the fact foreach is used with arrays, and from what ive tested the error dissapears the moment i introduce the Variables to an array like so.

<?php

$global_whati = array();
$left = "{";
$right = "}";
foreach($global_whati as $sillyvar)
{
$global_what[] = $left.$sillyvar.$right;
}
$data = str_replace($global_what, $global_with, $data);

$whati = array();
foreach($whati as $sillyvar)
{
}
?>

also i removed all unnessicary white space..

i found no error to print out once the array was established.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
ori Lead · 512 posts #3

this what i use as you can see ive used curl before or you can use file_get_contents all it is is function to read data from template ex insert php data into the page templates, you have global data and then you have page by page data

/////GLOBALS WHAT/////
$global_what = Array(
'baseaddr',
'action',
'mode',
'directory',
'images',
'sitename',
'site',
'sitecolor',
'shadow',
'username',
'uid',
'mobads',
'mobads2',
'ipaddress',
'browser',
'email',
'mysql_error'
);

/////GLOBALS WITH/////

$global_with = Array(
$baseaddr,
$action,
$mod,
$directory,
$images,
$sitename,
$_SESSION['sitename'],
$_SESSION['navcolor'],
$_SESSION['sitecolor_shadow'],
$_SESSION['username'],
$_SESSION['uid'],
"<a href=\"http://info.wapdesire.com\">click here for help</a>",
"<a href=\"http://info.wapdesire.com\">click here for help</a>",
ip(),
browser($_SERVER['HTTP_USER_AGENT']),
fetch_array("email",members,"id = 1"),
$mysqlerror
);
function Template($what, $with, $temp)
{
global $global_what,$global_with;
if (!is_file("./templates/$temp.xhtml")) error("file not found!");
$data = file_get_contents("./templates/$temp.html",1);
/*
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, "http://www.wapdesire.com/templates/$temp.html");
curl_setopt($cURL, CURLOPT_HEADER, 0);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($cURL);
curl_close($cURL);
*/
foreach($what as $getvar) $What[] = "{".$getvar."}";
$data = str_replace($What, $with, $data);
foreach($global_what as $getvar) $Global_what[] = "{".$getvar."}";
$data = str_replace($Global_what, $global_with, $data);
print $data;
}

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close