0

I am following the http://www.raywenderlich.com/13511/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-12#comments tutorial. I opened an XAMPP server and when I opened http://localhost/iReporter because iReporter is the name of the folder and the error was

Parse error: syntax error, unexpected T_STRING in /Applications/XAMPP/xamppfiles/htdocs/iReporter/lib.php on line 5

here is the code for lib.php:

<?

//setup db connection

$link = mysqli_connect("localhost","root","")

mysqli_select_db($link, "iReport");

//executes a given sql query with the params and returns an array as result function
query() {

global $link;

$debug = false;

//get the sql query
$args = func_get_args();
$sql = array_shift($args);
//secure the input
for ($i=0;$i<count($args);$i++) {
    $args[$i] = urldecode($args[$i]);
    $args[$i] = mysqli_real_escape_string($link, $args[$i]);
}

//build the final query
$sql = vsprintf($sql, $args);

if ($debug) print $sql;

//execute and fetch the results
$result = mysqli_query($link, $sql);
if (mysqli_errno($link)==0 && $result) {

    $rows = array();
    if ($result!==true)
    while ($d = mysqli_fetch_assoc($result)) {
        array_push($rows,$d);
    }

    //return json
    return array('result'=>$rows);

} else {

    //error
    return array('error'=>'Database error');
}

}

//loads up the source image, resizes it and saves with -thumb in the file name function thumb($srcFile, $sideInPx) {

$image = imagecreatefromjpeg($srcFile);

$width = imagesx($image);

$height = imagesy($image);

$thumb = imagecreatetruecolor($sideInPx, $sideInPx);

imagecopyresized($thumb,$image,0,0,0,0,$sideInPx,$sideInPx,$width,$height);

imagejpeg($thumb, str_replace(".jpg","-thumb.jpg",$srcFile), 85);

imagedestroy($thumb); imagedestroy($image); }

?>

What is my problem? Please Help!

--Edit--

now it says that there is an error with line 35 when I changed $link = mysqli_connect("localhost","root","") to $link = mysqli_connect("localhost","root","");!

1 Answer 1

1

there is a mising ";" in the line

$link = mysqli_connect("localhost","root","")

and must be

$link = mysqli_connect("localhost","root","");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.